| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976 |
- {
- "info": {
- "_postman_id": "5b90b987-503f-484c-b8d7-a0974674e95d",
- "name": "t-erp-auto-test",
- "description": "T系列ERP自动化测试集合\\[for Jenkins\\]",
- "schema": "https://schema.getpostman.com/json/collection/v2.1.0/collection.json",
- "_exporter_id": "3170378",
- "_collection_link": "https://go.postman.co/collection/3170378-5b90b987-503f-484c-b8d7-a0974674e95d?source=collection_link"
- },
- "item": [
- {
- "name": "登录",
- "item": [
- {
- "name": "登录",
- "event": [
- {
- "listen": "test",
- "script": {
- "exec": [
- "// 登录测试脚本",
- "// ===================== status:状态码 =====================",
- "pm.test(\"✅ 状态码 200\", () => pm.response.to.have.status(200));",
- "// =========================================================",
- "",
- "var jsonData = pm.response.json();",
- "// ===================== console:按需打印 =====================",
- "// 1. 单个关键值打印(按需选择)",
- "console.log(`📋 登录接口返回CompNo:${jsonData.CompNo}`);",
- "console.log(`📋 登录接口返回UserNo:${jsonData.UserNo}`);",
- "console.log(`📋 生成的登录令牌LoginId:${jsonData.LoginId}`);",
- "console.log(`📋 令牌有效期LoginIdExpiry:${jsonData.LoginIdExpiry} 秒`);",
- "",
- "// 2. 批量打印多个核心值(推荐,日志更集中,少占行数)",
- "console.log(\"📋 登录接口核心返回值汇总:\", {",
- " LoginId: jsonData.LoginId,",
- " CompNo: jsonData.CompNo,",
- " UserNo: jsonData.UserNo,",
- " LoginIdExpiry: jsonData.LoginIdExpiry,",
- " ClientType: jsonData.ClientType",
- "});",
- "",
- "// 3. 打印刚设置的环境变量(验证是否保存成功,可选)",
- "console.info(`🔧 环境变量已设置t-erp-api-login-id:${pm.environment.get(\"t-erp-api-login-id\")}`);",
- "// ======================================================================",
- "",
- "// ===================== test:按需验证 =====================",
- "pm.test(\"✅ 必需字段存在\", () => {",
- " pm.expect(jsonData).to.include.all.keys(",
- " 'LoginId', 'CompNo', 'UserNo', 'LoginIdExpiry'",
- " );",
- "});",
- "pm.test(\"✅ 登录信息正确\", () => {",
- " pm.expect(jsonData.CompNo).to.equal('TAPI');",
- " pm.expect(jsonData.UserNo).to.equal('API');",
- " pm.expect(jsonData.ClientType).to.equal('JksAutoTestApi');",
- " pm.expect(jsonData.LoginIdExpiry).to.equal(604800);",
- "});",
- "pm.test(\"✅ 保存登录令牌成功\", () => {",
- " pm.expect(jsonData.LoginId).to.be.a('string').and.not.empty;",
- " pm.environment.set(\"t-erp-api-login-id\", jsonData.LoginId);",
- "});",
- "// ======================================================================"
- ],
- "type": "text/javascript",
- "packages": {},
- "requests": {}
- }
- }
- ],
- "request": {
- "auth": {
- "type": "noauth"
- },
- "method": "POST",
- "header": [
- {
- "key": "LanguageId",
- "value": "{{t-erp-api-language}}",
- "description": "0:简体;1:繁体;2:英文"
- },
- {
- "key": "Authorization",
- "value": "{{t-erp-api-authorization}}",
- "description": "服务:237;账套:TAPI;用户:API"
- },
- {
- "key": "ClientType",
- "value": "{{t-erp-api-client-type}}",
- "description": "JksAutoTestApi"
- },
- {
- "key": "Content-Type",
- "value": "{{t-erp-api-content-type}}",
- "description": "application/json"
- },
- {
- "key": "X-Tiansi-Auth-Bypass",
- "value": "{{t-erp-api-x-tiansi-bypass}}",
- "description": "跳过接口注册检验",
- "type": "text"
- },
- {
- "key": "sn",
- "value": "{{t-erp-api-sn}}",
- "description": "用于Linker定位ERP服务",
- "type": "text"
- }
- ],
- "url": {
- "raw": "{{t-erp-api-url}}/User/login",
- "host": [
- "{{t-erp-api-url}}"
- ],
- "path": [
- "User",
- "login"
- ]
- },
- "description": "登录系统"
- },
- "response": []
- }
- ],
- "description": "登录"
- },
- {
- "name": "部门资料",
- "item": [
- {
- "name": "新增部门",
- "event": [
- {
- "listen": "test",
- "script": {
- "exec": [
- "// 完整可用的部门接口测试脚本\r",
- "pm.test(\"✅ 状态码 200\", () => pm.response.to.have.status(200));\r",
- "\r",
- "var requestData = JSON.parse(pm.request.body.raw);\r",
- "var responseData = pm.response.json();\r",
- "\r",
- "// 1. 验证响应结构\r",
- "pm.test(\"📋 响应结构验证\", () => {\r",
- " pm.expect(responseData).to.have.all.keys('OkCount', 'ErrorCount', 'ErrorData');\r",
- " pm.expect(responseData.OkCount).to.be.a('number');\r",
- " pm.expect(responseData.ErrorCount).to.be.a('number');\r",
- " pm.expect(responseData.ErrorData).to.be.an('array');\r",
- "});\r",
- "\r",
- "// 2. 验证请求数据(修正后的正确写法)\r",
- "pm.test(\"✅ 请求部门数据验证\", () => {\r",
- " pm.expect(requestData).to.be.an('array').that.is.not.empty;\r",
- " \r",
- " requestData.forEach((dept, idx) => {\r",
- " const deptNum = idx + 1;\r",
- " \r",
- " // 验证必填字段存在\r",
- " pm.expect(dept, `部门${deptNum}`).to.include.keys('DEP', 'NAME');\r",
- " \r",
- " // 验证字段类型和值\r",
- " pm.expect(dept.DEP, `部门${deptNum}的部门代码`).to.be.a('string').that.is.not.empty;\r",
- " pm.expect(dept.NAME, `部门${deptNum}的部门名称`).to.be.a('string').that.is.not.empty;\r",
- " \r",
- " // 可选字段验证\r",
- " if (dept.ENG_NAME !== undefined) {\r",
- " pm.expect(dept.ENG_NAME).to.be.a('string');\r",
- " }\r",
- " \r",
- " if (dept.UP !== undefined) {\r",
- " pm.expect(dept.UP).to.be.a('string');\r",
- " }\r",
- " });\r",
- "});\r",
- "\r",
- "// 3. 验证业务结果\r",
- "pm.test(\"📊 操作结果验证\", () => {\r",
- " const total = requestData.length;\r",
- " \r",
- " pm.expect(responseData.OkCount + responseData.ErrorCount).to.equal(total);\r",
- " \r",
- " if (responseData.ErrorCount === 0) {\r",
- " pm.expect(responseData.OkCount).to.equal(total);\r",
- " pm.expect(responseData.ErrorData).to.eql([]);\r",
- " console.log(`✅ 成功处理 ${responseData.OkCount} 个部门`);\r",
- " } else {\r",
- " console.log(`⚠️ 部分失败: ${responseData.OkCount} 成功, ${responseData.ErrorCount} 失败`);\r",
- " \r",
- " // 验证错误数据\r",
- " responseData.ErrorData.forEach(error => {\r",
- " pm.expect(error).to.include.keys('Index', 'DEP', 'ErrorMessage');\r",
- " pm.expect(error.Index).to.be.within(0, total - 1);\r",
- " });\r",
- " }\r",
- "});"
- ],
- "type": "text/javascript",
- "packages": {},
- "requests": {}
- }
- }
- ],
- "request": {
- "method": "POST",
- "header": [
- {
- "key": "LoginId",
- "value": "{{t-erp-api-login-id}}",
- "type": "text"
- },
- {
- "key": "sn",
- "value": "{{t-erp-api-sn}}",
- "type": "text"
- }
- ],
- "body": {
- "mode": "raw",
- "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]",
- "options": {
- "raw": {
- "language": "json"
- }
- }
- },
- "url": {
- "raw": "{{t-erp-api-url}}/Dept/AppendToDept",
- "host": [
- "{{t-erp-api-url}}"
- ],
- "path": [
- "Dept",
- "AppendToDept"
- ]
- },
- "description": "新增部门资料"
- },
- "response": []
- },
- {
- "name": "删除部门",
- "event": [
- {
- "listen": "test",
- "script": {
- "exec": [
- "// 简化版删除部门测试脚本\r",
- "pm.test(\"✅ 状态码 200\", () => pm.response.to.have.status(200));\r",
- "\r",
- "var requestData = JSON.parse(pm.request.body.raw);\r",
- "var responseData = pm.response.json();\r",
- "\r",
- "// 基础验证\r",
- "pm.test(\"✅ 响应结构验证\", () => {\r",
- " pm.expect(responseData).to.have.all.keys('OkCount', 'ErrorCount', 'ErrorData');\r",
- "});\r",
- "\r",
- "// 请求数据验证\r",
- "pm.test(\"✅ 删除请求数据验证\", () => {\r",
- " pm.expect(requestData).to.be.an('array').that.is.not.empty;\r",
- " \r",
- " requestData.forEach((item, index) => {\r",
- " pm.expect(item).to.have.property('DEP');\r",
- " pm.expect(item.DEP).to.be.a('string').and.not.empty;\r",
- " });\r",
- " \r",
- " console.log(`🗑️ 请求删除 ${requestData.length} 个部门`);\r",
- "});\r",
- "\r",
- "// 业务结果验证\r",
- "pm.test(\"📊 删除结果验证\", () => {\r",
- " const total = requestData.length;\r",
- " \r",
- " // 验证计数逻辑\r",
- " pm.expect(responseData.OkCount + responseData.ErrorCount).to.equal(total);\r",
- " \r",
- " // 根据成功示例验证\r",
- " pm.expect(responseData.ErrorCount).to.equal(0);\r",
- " pm.expect(responseData.OkCount).to.equal(total);\r",
- " pm.expect(responseData.ErrorData).to.eql([]);\r",
- " \r",
- " console.log(`✅ 成功删除 ${responseData.OkCount} 个部门`);\r",
- "});"
- ],
- "type": "text/javascript",
- "packages": {},
- "requests": {}
- }
- }
- ],
- "request": {
- "method": "POST",
- "header": [
- {
- "key": "LoginId",
- "value": "{{t-erp-api-login-id}}",
- "type": "text"
- },
- {
- "key": "sn",
- "value": "{{t-erp-api-sn}}",
- "type": "text"
- }
- ],
- "body": {
- "mode": "raw",
- "raw": "[\r\n {\r\n \"DEP\": \"0003\" // 必须,部门代号,删除该笔部门资料\r\n }\r\n]",
- "options": {
- "raw": {
- "language": "json"
- }
- }
- },
- "url": {
- "raw": "{{t-erp-api-url}}/Dept/DeleteForDept",
- "host": [
- "{{t-erp-api-url}}"
- ],
- "path": [
- "Dept",
- "DeleteForDept"
- ]
- },
- "description": "删除部门资料"
- },
- "response": []
- }
- ],
- "description": "部门资料"
- },
- {
- "name": "员工资料",
- "item": [
- {
- "name": "新增员工",
- "event": [
- {
- "listen": "test",
- "script": {
- "exec": [
- "// 1. 基础响应验证\r",
- "pm.test(\"✅ 状态码 200\", function() {\r",
- " pm.response.to.have.status(200);\r",
- "});\r",
- "\r",
- "// 2. 获取数据\r",
- "var requestData = JSON.parse(pm.request.body.raw);\r",
- "var responseData = pm.response.json();\r",
- "\r",
- "// 3. 响应结构验证\r",
- "pm.test(\"📋 响应结构验证\", function() {\r",
- " pm.expect(responseData).to.have.all.keys('OkCount', 'ErrorCount', 'ErrorData');\r",
- " pm.expect(responseData.OkCount).to.be.a('number');\r",
- " pm.expect(responseData.ErrorCount).to.be.a('number');\r",
- " pm.expect(responseData.ErrorData).to.be.an('array');\r",
- "});\r",
- "\r",
- "// 4. 请求数据验证\r",
- "pm.test(\"✅ 员工数据验证\", function() {\r",
- " pm.expect(requestData).to.be.an('array').that.is.not.empty;\r",
- " \r",
- " requestData.forEach((employee, index) => {\r",
- " const empNum = index + 1;\r",
- " \r",
- " // 必填字段验证\r",
- " pm.expect(employee, `员工${empNum}`).to.include.keys('SAL_NO', 'NAME', 'DEP');\r",
- " pm.expect(employee.SAL_NO, `员工${empNum}工号`).to.be.a('string').and.not.empty;\r",
- " pm.expect(employee.NAME, `员工${empNum}姓名`).to.be.a('string').and.not.empty;\r",
- " pm.expect(employee.DEP, `员工${empNum}部门`).to.be.a('string').and.not.empty;\r",
- " \r",
- " // 可选字段类型验证(如果存在)\r",
- " if (employee.POS !== undefined) {\r",
- " pm.expect(employee.POS).to.be.a('string');\r",
- " }\r",
- " if (employee.UP_SAL_NO !== undefined) {\r",
- " pm.expect(employee.UP_SAL_NO).to.be.a('string');\r",
- " }\r",
- " if (employee.TOPSWD !== undefined) {\r",
- " pm.expect(employee.TOPSWD).to.be.a('string');\r",
- " }\r",
- " if (employee.REM !== undefined) {\r",
- " pm.expect(employee.REM).to.be.a('string');\r",
- " }\r",
- " });\r",
- " \r",
- " console.log(`✅ 已验证 ${requestData.length} 个员工数据`);\r",
- "});\r",
- "\r",
- "// 5. 业务结果验证\r",
- "pm.test(\"📊 操作结果验证\", function() {\r",
- " const total = requestData.length;\r",
- " \r",
- " // 验证计数逻辑\r",
- " pm.expect(responseData.OkCount + responseData.ErrorCount).to.equal(total);\r",
- " \r",
- " // 根据成功示例验证\r",
- " pm.expect(responseData.ErrorCount, \"失败数量\").to.equal(0);\r",
- " pm.expect(responseData.OkCount, \"成功数量\").to.equal(total);\r",
- " pm.expect(responseData.ErrorData, \"错误数据\").to.eql([]);\r",
- " \r",
- " console.log(`✅ 成功处理 ${responseData.OkCount}/${total} 个员工`);\r",
- "});"
- ],
- "type": "text/javascript",
- "packages": {},
- "requests": {}
- }
- }
- ],
- "request": {
- "method": "POST",
- "header": [
- {
- "key": "LoginId",
- "value": "{{t-erp-api-login-id}}",
- "type": "text"
- },
- {
- "key": "sn",
- "value": "{{t-erp-api-sn}}",
- "type": "text"
- }
- ],
- "body": {
- "mode": "raw",
- "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]",
- "options": {
- "raw": {
- "language": "json"
- }
- }
- },
- "url": {
- "raw": "{{t-erp-api-url}}/Salm/AppendToSalm",
- "host": [
- "{{t-erp-api-url}}"
- ],
- "path": [
- "Salm",
- "AppendToSalm"
- ]
- },
- "description": "新增员工资料"
- },
- "response": []
- },
- {
- "name": "删除员工",
- "event": [
- {
- "listen": "test",
- "script": {
- "exec": [
- "// 1. 基础响应验证\r",
- "pm.test(\"✅ 状态码 200\", function() {\r",
- " pm.response.to.have.status(200);\r",
- "});\r",
- "\r",
- "// 2. 获取数据\r",
- "var requestData = JSON.parse(pm.request.body.raw);\r",
- "var responseData = pm.response.json();\r",
- "\r",
- "// 3. 响应结构验证\r",
- "pm.test(\"📋 响应结构验证\", function() {\r",
- " pm.expect(responseData).to.have.all.keys('OkCount', 'ErrorCount', 'ErrorData');\r",
- " pm.expect(responseData.OkCount).to.be.a('number');\r",
- " pm.expect(responseData.ErrorCount).to.be.a('number');\r",
- " pm.expect(responseData.ErrorData).to.be.an('array');\r",
- "});\r",
- "\r",
- "// 4. 请求数据验证\r",
- "pm.test(\"✅ 删除请求验证\", function() {\r",
- " pm.expect(requestData).to.be.an('array').that.is.not.empty;\r",
- " \r",
- " requestData.forEach((item, index) => {\r",
- " const itemNum = index + 1;\r",
- " \r",
- " // 必填字段验证\r",
- " pm.expect(item, `删除项${itemNum}`).to.have.property('SAL_NO');\r",
- " pm.expect(item.SAL_NO, `员工${itemNum}工号`).to.be.a('string').and.not.empty;\r",
- " });\r",
- " \r",
- " console.log(`🗑️ 请求删除 ${requestData.length} 个员工`);\r",
- "});\r",
- "\r",
- "// 5. 业务结果验证\r",
- "pm.test(\"📊 删除结果验证\", function() {\r",
- " const total = requestData.length;\r",
- " \r",
- " // 验证计数逻辑\r",
- " pm.expect(responseData.OkCount + responseData.ErrorCount).to.equal(total);\r",
- " \r",
- " // 根据成功示例验证\r",
- " pm.expect(responseData.ErrorCount, \"失败数量\").to.equal(0);\r",
- " pm.expect(responseData.OkCount, \"成功数量\").to.equal(total);\r",
- " pm.expect(responseData.ErrorData, \"错误数据\").to.eql([]);\r",
- " \r",
- " console.log(`✅ 成功删除 ${responseData.OkCount}/${total} 个员工`);\r",
- "});"
- ],
- "type": "text/javascript",
- "packages": {},
- "requests": {}
- }
- }
- ],
- "request": {
- "method": "POST",
- "header": [
- {
- "key": "LoginId",
- "value": "{{t-erp-api-login-id}}",
- "type": "text"
- },
- {
- "key": "sn",
- "value": "{{t-erp-api-sn}}",
- "type": "text"
- }
- ],
- "body": {
- "mode": "raw",
- "raw": "[\r\n {\r\n \"SAL_NO\": \"WW\" // 必须,员工代号,删除该笔员工资料\r\n }\r\n]",
- "options": {
- "raw": {
- "language": "json"
- }
- }
- },
- "url": {
- "raw": "{{t-erp-api-url}}/Salm/DeleteForSalm",
- "host": [
- "{{t-erp-api-url}}"
- ],
- "path": [
- "Salm",
- "DeleteForSalm"
- ]
- },
- "description": "删除员工资料"
- },
- "response": []
- }
- ],
- "description": "员工资料"
- },
- {
- "name": "仓库资料",
- "item": [
- {
- "name": "新增仓库",
- "event": [
- {
- "listen": "test",
- "script": {
- "exec": [
- "// 1. 基础响应验证\r",
- "pm.test(\"✅ 状态码 200\", function() {\r",
- " pm.response.to.have.status(200);\r",
- "});\r",
- "\r",
- "// 2. 获取数据\r",
- "var requestData = JSON.parse(pm.request.body.raw);\r",
- "var responseData = pm.response.json();\r",
- "\r",
- "// 3. 响应结构验证\r",
- "pm.test(\"📋 响应结构验证\", function() {\r",
- " pm.expect(responseData).to.have.all.keys('OkCount', 'ErrorCount', 'ErrorData');\r",
- " pm.expect(responseData.OkCount).to.be.a('number');\r",
- " pm.expect(responseData.ErrorCount).to.be.a('number');\r",
- " pm.expect(responseData.ErrorData).to.be.an('array');\r",
- "});\r",
- "\r",
- "// 4. 请求数据验证\r",
- "pm.test(\"✅ 仓库数据验证\", function() {\r",
- " pm.expect(requestData).to.be.an('array').that.is.not.empty;\r",
- " \r",
- " requestData.forEach((warehouse, index) => {\r",
- " const whNum = index + 1;\r",
- " \r",
- " // 必填字段验证\r",
- " pm.expect(warehouse, `仓库${whNum}`).to.include.keys('WH', 'NAME');\r",
- " pm.expect(warehouse.WH, `仓库${whNum}代号`).to.be.a('string').and.not.empty;\r",
- " pm.expect(warehouse.NAME, `仓库${whNum}名称`).to.be.a('string').and.not.empty;\r",
- " \r",
- " // 可选字段类型验证(如果存在)\r",
- " const optionalFields = ['ATTRIB', 'UP_WH', 'INVALID', 'VMIVALID', 'LOC_ID', 'OUT_ID'];\r",
- " optionalFields.forEach(field => {\r",
- " if (warehouse[field] !== undefined) {\r",
- " pm.expect(warehouse[field]).to.be.a('string');\r",
- " }\r",
- " });\r",
- " });\r",
- " \r",
- " console.log(`✅ 已验证 ${requestData.length} 个仓库数据`);\r",
- "});\r",
- "\r",
- "// 5. 业务结果验证\r",
- "pm.test(\"📊 操作结果验证\", function() {\r",
- " const total = requestData.length;\r",
- " \r",
- " // 验证计数逻辑\r",
- " pm.expect(responseData.OkCount + responseData.ErrorCount).to.equal(total);\r",
- " \r",
- " // 根据成功示例验证\r",
- " pm.expect(responseData.ErrorCount, \"失败数量\").to.equal(0);\r",
- " pm.expect(responseData.OkCount, \"成功数量\").to.equal(total);\r",
- " pm.expect(responseData.ErrorData, \"错误数据\").to.eql([]);\r",
- " \r",
- " console.log(`✅ 成功处理 ${responseData.OkCount}/${total} 个仓库`);\r",
- "});"
- ],
- "type": "text/javascript",
- "packages": {},
- "requests": {}
- }
- }
- ],
- "request": {
- "method": "POST",
- "header": [
- {
- "key": "LoginId",
- "value": "{{t-erp-api-login-id}}",
- "type": "text"
- },
- {
- "key": "sn",
- "value": "{{t-erp-api-sn}}",
- "type": "text"
- }
- ],
- "body": {
- "mode": "raw",
- "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]",
- "options": {
- "raw": {
- "language": "json"
- }
- }
- },
- "url": {
- "raw": "{{t-erp-api-url}}/Wh/AppendToWh",
- "host": [
- "{{t-erp-api-url}}"
- ],
- "path": [
- "Wh",
- "AppendToWh"
- ]
- },
- "description": "新增仓库资料"
- },
- "response": []
- }
- ],
- "description": "仓库资料"
- },
- {
- "name": "货品资料",
- "item": [
- {
- "name": "新增货品",
- "event": [
- {
- "listen": "test",
- "script": {
- "exec": [
- "// 1. 基础响应验证\r",
- "pm.test(\"✅ 状态码 200\", function() {\r",
- " pm.response.to.have.status(200);\r",
- "});\r",
- "\r",
- "// 2. 获取数据\r",
- "var requestData = JSON.parse(pm.request.body.raw);\r",
- "var responseData = pm.response.json();\r",
- "\r",
- "// 3. 响应结构验证\r",
- "pm.test(\"📋 响应结构验证\", function() {\r",
- " pm.expect(responseData).to.have.all.keys('OkCount', 'ErrorCount', 'ErrorData');\r",
- " pm.expect(responseData.OkCount).to.be.a('number');\r",
- " pm.expect(responseData.ErrorCount).to.be.a('number');\r",
- " pm.expect(responseData.ErrorData).to.be.an('array');\r",
- "});\r",
- "\r",
- "// 4. 请求数据验证\r",
- "pm.test(\"✅ 货品数据验证\", function() {\r",
- " pm.expect(requestData).to.be.an('array').that.is.not.empty;\r",
- " \r",
- " requestData.forEach((product, index) => {\r",
- " const prodNum = index + 1;\r",
- " \r",
- " // 必填字段验证\r",
- " pm.expect(product, `货品${prodNum}`).to.include.keys('PRD_NO', 'NAME', 'UT');\r",
- " pm.expect(product.PRD_NO, `货品${prodNum}代号`).to.be.a('string').and.not.empty;\r",
- " pm.expect(product.NAME, `货品${prodNum}名称`).to.be.a('string').and.not.empty;\r",
- " pm.expect(product.UT, `货品${prodNum}单位`).to.be.a('string').and.not.empty;\r",
- " \r",
- " // 可选字段类型验证(如果存在)\r",
- " const optionalFields = ['WH', 'REM', 'CHK_BAT', 'CHK_MARK'];\r",
- " optionalFields.forEach(field => {\r",
- " if (product[field] !== undefined) {\r",
- " pm.expect(product[field]).to.be.a('string');\r",
- " }\r",
- " });\r",
- " });\r",
- " \r",
- " console.log(`✅ 已验证 ${requestData.length} 个货品数据`);\r",
- "});\r",
- "\r",
- "// 5. 业务结果验证\r",
- "pm.test(\"📊 操作结果验证\", function() {\r",
- " const total = requestData.length;\r",
- " \r",
- " // 验证计数逻辑\r",
- " pm.expect(responseData.OkCount + responseData.ErrorCount).to.equal(total);\r",
- " \r",
- " // 根据成功示例验证\r",
- " pm.expect(responseData.ErrorCount, \"失败数量\").to.equal(0);\r",
- " pm.expect(responseData.OkCount, \"成功数量\").to.equal(total);\r",
- " pm.expect(responseData.ErrorData, \"错误数据\").to.eql([]);\r",
- " \r",
- " console.log(`✅ 成功处理 ${responseData.OkCount}/${total} 个货品`);\r",
- "});"
- ],
- "type": "text/javascript",
- "packages": {},
- "requests": {}
- }
- }
- ],
- "request": {
- "method": "POST",
- "header": [
- {
- "key": "LoginId",
- "value": "{{t-erp-api-login-id}}",
- "type": "text"
- },
- {
- "key": "sn",
- "value": "{{t-erp-api-sn}}",
- "type": "text"
- }
- ],
- "body": {
- "mode": "raw",
- "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]",
- "options": {
- "raw": {
- "language": "json"
- }
- }
- },
- "url": {
- "raw": "{{t-erp-api-url}}/Prdt/AppendToPrdt",
- "host": [
- "{{t-erp-api-url}}"
- ],
- "path": [
- "Prdt",
- "AppendToPrdt"
- ]
- },
- "description": "新增货品"
- },
- "response": []
- },
- {
- "name": "删除货品",
- "event": [
- {
- "listen": "test",
- "script": {
- "exec": [
- "// 1. 基础响应验证\r",
- "pm.test(\"✅ 状态码 200\", function() {\r",
- " pm.response.to.have.status(200);\r",
- "});\r",
- "\r",
- "// 2. 获取数据\r",
- "var requestData = JSON.parse(pm.request.body.raw);\r",
- "var responseData = pm.response.json();\r",
- "\r",
- "// 3. 响应结构验证\r",
- "pm.test(\"📋 响应结构验证\", function() {\r",
- " pm.expect(responseData).to.have.all.keys('OkCount', 'ErrorCount', 'ErrorData');\r",
- " pm.expect(responseData.OkCount).to.be.a('number');\r",
- " pm.expect(responseData.ErrorCount).to.be.a('number');\r",
- " pm.expect(responseData.ErrorData).to.be.an('array');\r",
- "});\r",
- "\r",
- "// 4. 请求数据验证\r",
- "pm.test(\"✅ 删除请求验证\", function() {\r",
- " pm.expect(requestData).to.be.an('array').that.is.not.empty;\r",
- " \r",
- " requestData.forEach((item, index) => {\r",
- " const itemNum = index + 1;\r",
- " \r",
- " // 必填字段验证\r",
- " pm.expect(item, `删除项${itemNum}`).to.have.property('PRD_NO');\r",
- " pm.expect(item.PRD_NO, `货品${itemNum}代号`).to.be.a('string').and.not.empty;\r",
- " });\r",
- " \r",
- " console.log(`🗑️ 请求删除 ${requestData.length} 个货品`);\r",
- "});\r",
- "\r",
- "// 5. 业务结果验证\r",
- "pm.test(\"📊 删除结果验证\", function() {\r",
- " const total = requestData.length;\r",
- " \r",
- " // 验证计数逻辑\r",
- " pm.expect(responseData.OkCount + responseData.ErrorCount).to.equal(total);\r",
- " \r",
- " // 根据成功示例验证\r",
- " pm.expect(responseData.ErrorCount, \"失败数量\").to.equal(0);\r",
- " pm.expect(responseData.OkCount, \"成功数量\").to.equal(total);\r",
- " pm.expect(responseData.ErrorData, \"错误数据\").to.eql([]);\r",
- " \r",
- " console.log(`✅ 成功删除 ${responseData.OkCount}/${total} 个货品`);\r",
- "});"
- ],
- "type": "text/javascript",
- "packages": {},
- "requests": {}
- }
- }
- ],
- "request": {
- "method": "POST",
- "header": [
- {
- "key": "LoginId",
- "value": "{{t-erp-api-login-id}}",
- "type": "text"
- },
- {
- "key": "sn",
- "value": "{{t-erp-api-sn}}",
- "type": "text"
- }
- ],
- "body": {
- "mode": "raw",
- "raw": "[\r\n {\r\n \"PRD_NO\": \"YL0002\" // 必须,货品代号,删除该笔货品资料\r\n }\r\n]",
- "options": {
- "raw": {
- "language": "json"
- }
- }
- },
- "url": {
- "raw": "{{t-erp-api-url}}/Prdt/DeleteForPrdt",
- "host": [
- "{{t-erp-api-url}}"
- ],
- "path": [
- "Prdt",
- "DeleteForPrdt"
- ]
- },
- "description": "删除货品资料"
- },
- "response": []
- }
- ],
- "description": "货品资料"
- },
- {
- "name": "客户厂商资料",
- "item": [
- {
- "name": "新增客户",
- "event": [
- {
- "listen": "test",
- "script": {
- "exec": [
- "// 1. 基础响应验证\r",
- "pm.test(\"✅ 状态码 200\", function() {\r",
- " pm.response.to.have.status(200);\r",
- "});\r",
- "\r",
- "// 2. 获取数据\r",
- "var requestData = JSON.parse(pm.request.body.raw);\r",
- "var responseData = pm.response.json();\r",
- "\r",
- "// 3. 响应结构验证\r",
- "pm.test(\"📋 响应结构验证\", function() {\r",
- " pm.expect(responseData).to.have.all.keys('OkCount', 'ErrorCount', 'ErrorData');\r",
- " pm.expect(responseData.OkCount).to.be.a('number');\r",
- " pm.expect(responseData.ErrorCount).to.be.a('number');\r",
- " pm.expect(responseData.ErrorData).to.be.an('array');\r",
- "});\r",
- "\r",
- "// 4. 请求数据验证\r",
- "pm.test(\"✅ 客户数据验证\", function() {\r",
- " pm.expect(requestData).to.be.an('array').that.is.not.empty;\r",
- " \r",
- " requestData.forEach((customer, index) => {\r",
- " const custNum = index + 1;\r",
- " \r",
- " // 必填字段验证\r",
- " pm.expect(customer, `客户${custNum}`).to.include.keys('CUS_NO', 'OBJ_ID', 'NAME');\r",
- " pm.expect(customer.CUS_NO, `客户${custNum}代号`).to.be.a('string').and.not.empty;\r",
- " pm.expect(customer.NAME, `客户${custNum}名称`).to.be.a('string').and.not.empty;\r",
- " pm.expect(customer.OBJ_ID, `客户${custNum}对象别`).to.be.a('string');\r",
- " \r",
- " // 验证OBJ_ID取值范围\r",
- " const validObjIds = ['1', '2', '3'];\r",
- " if (customer.OBJ_ID && customer.OBJ_ID !== '') {\r",
- " pm.expect(validObjIds).to.include(\r",
- " customer.OBJ_ID,\r",
- " `客户${custNum}的OBJ_ID应为1、2或3,当前值为:${customer.OBJ_ID}`\r",
- " );\r",
- " }\r",
- " \r",
- " // 可选字段类型验证(如果存在)\r",
- " const optionalFields = ['SAL', 'ID1_TAX', 'MAS_CUS', 'REM'];\r",
- " optionalFields.forEach(field => {\r",
- " if (customer[field] !== undefined) {\r",
- " pm.expect(customer[field]).to.be.a('string');\r",
- " }\r",
- " });\r",
- " });\r",
- " \r",
- " console.log(`✅ 已验证 ${requestData.length} 个客户数据`);\r",
- "});\r",
- "\r",
- "// 5. 业务结果验证\r",
- "pm.test(\"📊 操作结果验证\", function() {\r",
- " const total = requestData.length;\r",
- " \r",
- " // 验证计数逻辑\r",
- " pm.expect(responseData.OkCount + responseData.ErrorCount).to.equal(total);\r",
- " \r",
- " // 根据成功示例验证\r",
- " pm.expect(responseData.ErrorCount, \"失败数量\").to.equal(0);\r",
- " pm.expect(responseData.OkCount, \"成功数量\").to.equal(total);\r",
- " pm.expect(responseData.ErrorData, \"错误数据\").to.eql([]);\r",
- " \r",
- " console.log(`✅ 成功处理 ${responseData.OkCount}/${total} 个客户`);\r",
- "});"
- ],
- "type": "text/javascript",
- "packages": {},
- "requests": {}
- }
- }
- ],
- "request": {
- "method": "POST",
- "header": [
- {
- "key": "LoginId",
- "value": "{{t-erp-api-login-id}}",
- "type": "text"
- },
- {
- "key": "sn",
- "value": "{{t-erp-api-sn}}",
- "type": "text"
- }
- ],
- "body": {
- "mode": "raw",
- "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]",
- "options": {
- "raw": {
- "language": "json"
- }
- }
- },
- "url": {
- "raw": "{{t-erp-api-url}}/Cust/AppendToCust",
- "host": [
- "{{t-erp-api-url}}"
- ],
- "path": [
- "Cust",
- "AppendToCust"
- ]
- },
- "description": "新增客户资料"
- },
- "response": []
- },
- {
- "name": "删除客户",
- "event": [
- {
- "listen": "test",
- "script": {
- "exec": [
- "// 1. 基础响应验证\r",
- "pm.test(\"✅ 状态码 200\", function() {\r",
- " pm.response.to.have.status(200);\r",
- "});\r",
- "\r",
- "// 2. 获取数据\r",
- "var requestData = JSON.parse(pm.request.body.raw);\r",
- "var responseData = pm.response.json();\r",
- "\r",
- "// 3. 响应结构验证\r",
- "pm.test(\"📋 响应结构验证\", function() {\r",
- " pm.expect(responseData).to.have.all.keys('OkCount', 'ErrorCount', 'ErrorData');\r",
- " pm.expect(responseData.OkCount).to.be.a('number');\r",
- " pm.expect(responseData.ErrorCount).to.be.a('number');\r",
- " pm.expect(responseData.ErrorData).to.be.an('array');\r",
- "});\r",
- "\r",
- "// 4. 请求数据验证\r",
- "pm.test(\"✅ 删除请求验证\", function() {\r",
- " pm.expect(requestData).to.be.an('array').that.is.not.empty;\r",
- " \r",
- " requestData.forEach((item, index) => {\r",
- " const itemNum = index + 1;\r",
- " \r",
- " // 必填字段验证\r",
- " pm.expect(item, `删除项${itemNum}`).to.have.property('CUS_NO');\r",
- " pm.expect(item.CUS_NO, `客户${itemNum}代号`).to.be.a('string').and.not.empty;\r",
- " });\r",
- " \r",
- " console.log(`🗑️ 请求删除 ${requestData.length} 个客户`);\r",
- "});\r",
- "\r",
- "// 5. 业务结果验证\r",
- "pm.test(\"📊 删除结果验证\", function() {\r",
- " const total = requestData.length;\r",
- " \r",
- " // 验证计数逻辑\r",
- " pm.expect(responseData.OkCount + responseData.ErrorCount).to.equal(total);\r",
- " \r",
- " // 根据成功示例验证\r",
- " pm.expect(responseData.ErrorCount, \"失败数量\").to.equal(0);\r",
- " pm.expect(responseData.OkCount, \"成功数量\").to.equal(total);\r",
- " pm.expect(responseData.ErrorData, \"错误数据\").to.eql([]);\r",
- " \r",
- " console.log(`✅ 成功删除 ${responseData.OkCount}/${total} 个客户`);\r",
- "});"
- ],
- "type": "text/javascript",
- "packages": {},
- "requests": {}
- }
- }
- ],
- "request": {
- "method": "POST",
- "header": [
- {
- "key": "LoginId",
- "value": "{{t-erp-api-login-id}}",
- "type": "text"
- },
- {
- "key": "sn",
- "value": "{{t-erp-api-sn}}",
- "type": "text"
- }
- ],
- "body": {
- "mode": "raw",
- "raw": "[\r\n {\r\n \"CUS_NO\": \"KH0003\" // 必须,客户厂商代号,删除该笔客户厂商资料\r\n }\r\n]",
- "options": {
- "raw": {
- "language": "json"
- }
- }
- },
- "url": {
- "raw": "{{t-erp-api-url}}/Cust/DeleteForCust",
- "host": [
- "{{t-erp-api-url}}"
- ],
- "path": [
- "Cust",
- "DeleteForCust"
- ]
- },
- "description": "删除客户资料"
- },
- "response": []
- },
- {
- "name": "新增厂商",
- "event": [
- {
- "listen": "test",
- "script": {
- "exec": [
- "// 1. 基础响应验证\r",
- "pm.test(\"✅ 状态码 200\", function() {\r",
- " pm.response.to.have.status(200);\r",
- "});\r",
- "\r",
- "// 2. 获取数据\r",
- "var requestData = JSON.parse(pm.request.body.raw);\r",
- "var responseData = pm.response.json();\r",
- "\r",
- "// 3. 响应结构验证\r",
- "pm.test(\"📋 响应结构验证\", function() {\r",
- " pm.expect(responseData).to.have.all.keys('OkCount', 'ErrorCount', 'ErrorData');\r",
- " pm.expect(responseData.OkCount).to.be.a('number');\r",
- " pm.expect(responseData.ErrorCount).to.be.a('number');\r",
- " pm.expect(responseData.ErrorData).to.be.an('array');\r",
- "});\r",
- "\r",
- "// 4. 请求数据验证\r",
- "pm.test(\"✅ 厂商数据验证\", function() {\r",
- " pm.expect(requestData).to.be.an('array').that.is.not.empty;\r",
- " \r",
- " requestData.forEach((supplier, index) => {\r",
- " const supNum = index + 1;\r",
- " \r",
- " // 必填字段验证\r",
- " pm.expect(supplier, `厂商${supNum}`).to.include.keys('CUS_NO', 'OBJ_ID', 'NAME');\r",
- " pm.expect(supplier.CUS_NO, `厂商${supNum}代号`).to.be.a('string').and.not.empty;\r",
- " pm.expect(supplier.NAME, `厂商${supNum}名称`).to.be.a('string').and.not.empty;\r",
- " pm.expect(supplier.OBJ_ID, `厂商${supNum}对象别`).to.be.a('string');\r",
- " \r",
- " // 验证OBJ_ID取值范围(这里厂商应该是2或3,但根据接口说明,1、2、3都允许)\r",
- " const validObjIds = ['1', '2', '3'];\r",
- " if (supplier.OBJ_ID && supplier.OBJ_ID !== '') {\r",
- " pm.expect(validObjIds).to.include(\r",
- " supplier.OBJ_ID,\r",
- " `厂商${supNum}的OBJ_ID应为1、2或3,当前值为:${supplier.OBJ_ID}`\r",
- " );\r",
- " }\r",
- " \r",
- " // 可选字段类型验证(如果存在)\r",
- " const optionalFields = ['SAL', 'ID1_TAX', 'MAS_CUS', 'REM'];\r",
- " optionalFields.forEach(field => {\r",
- " if (supplier[field] !== undefined) {\r",
- " pm.expect(supplier[field]).to.be.a('string');\r",
- " }\r",
- " });\r",
- " });\r",
- " \r",
- " console.log(`✅ 已验证 ${requestData.length} 个厂商数据`);\r",
- "});\r",
- "\r",
- "// 5. 业务结果验证\r",
- "pm.test(\"📊 操作结果验证\", function() {\r",
- " const total = requestData.length;\r",
- " \r",
- " // 验证计数逻辑\r",
- " pm.expect(responseData.OkCount + responseData.ErrorCount).to.equal(total);\r",
- " \r",
- " // 根据成功示例验证\r",
- " pm.expect(responseData.ErrorCount, \"失败数量\").to.equal(0);\r",
- " pm.expect(responseData.OkCount, \"成功数量\").to.equal(total);\r",
- " pm.expect(responseData.ErrorData, \"错误数据\").to.eql([]);\r",
- " \r",
- " console.log(`✅ 成功处理 ${responseData.OkCount}/${total} 个厂商`);\r",
- "});"
- ],
- "type": "text/javascript",
- "packages": {},
- "requests": {}
- }
- }
- ],
- "request": {
- "method": "POST",
- "header": [
- {
- "key": "LoginId",
- "value": "{{t-erp-api-login-id}}",
- "type": "text"
- },
- {
- "key": "sn",
- "value": "{{t-erp-api-sn}}",
- "type": "text"
- }
- ],
- "body": {
- "mode": "raw",
- "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]",
- "options": {
- "raw": {
- "language": "json"
- }
- }
- },
- "url": {
- "raw": "{{t-erp-api-url}}/Cust/AppendToCust",
- "host": [
- "{{t-erp-api-url}}"
- ],
- "path": [
- "Cust",
- "AppendToCust"
- ]
- },
- "description": "新增厂商资料"
- },
- "response": []
- },
- {
- "name": "删除厂商",
- "event": [
- {
- "listen": "test",
- "script": {
- "exec": [
- "// 1. 基础响应验证\r",
- "pm.test(\"✅ 状态码 200\", function() {\r",
- " pm.response.to.have.status(200);\r",
- "});\r",
- "\r",
- "// 2. 获取数据\r",
- "var requestData = JSON.parse(pm.request.body.raw);\r",
- "var responseData = pm.response.json();\r",
- "\r",
- "// 3. 响应结构验证\r",
- "pm.test(\"📋 响应结构验证\", function() {\r",
- " pm.expect(responseData).to.have.all.keys('OkCount', 'ErrorCount', 'ErrorData');\r",
- " pm.expect(responseData.OkCount).to.be.a('number');\r",
- " pm.expect(responseData.ErrorCount).to.be.a('number');\r",
- " pm.expect(responseData.ErrorData).to.be.an('array');\r",
- "});\r",
- "\r",
- "// 4. 请求数据验证\r",
- "pm.test(\"✅ 删除请求验证\", function() {\r",
- " pm.expect(requestData).to.be.an('array').that.is.not.empty;\r",
- " \r",
- " requestData.forEach((item, index) => {\r",
- " const itemNum = index + 1;\r",
- " \r",
- " // 必填字段验证\r",
- " pm.expect(item, `删除项${itemNum}`).to.have.property('CUS_NO');\r",
- " pm.expect(item.CUS_NO, `厂商${itemNum}代号`).to.be.a('string').and.not.empty;\r",
- " });\r",
- " \r",
- " console.log(`🗑️ 请求删除 ${requestData.length} 个厂商`);\r",
- "});\r",
- "\r",
- "// 5. 业务结果验证\r",
- "pm.test(\"📊 删除结果验证\", function() {\r",
- " const total = requestData.length;\r",
- " \r",
- " // 验证计数逻辑\r",
- " pm.expect(responseData.OkCount + responseData.ErrorCount).to.equal(total);\r",
- " \r",
- " // 根据成功示例验证\r",
- " pm.expect(responseData.ErrorCount, \"失败数量\").to.equal(0);\r",
- " pm.expect(responseData.OkCount, \"成功数量\").to.equal(total);\r",
- " pm.expect(responseData.ErrorData, \"错误数据\").to.eql([]);\r",
- " \r",
- " console.log(`✅ 成功删除 ${responseData.OkCount}/${total} 个厂商`);\r",
- "});"
- ],
- "type": "text/javascript",
- "packages": {},
- "requests": {}
- }
- }
- ],
- "request": {
- "method": "POST",
- "header": [
- {
- "key": "LoginId",
- "value": "{{t-erp-api-login-id}}",
- "type": "text"
- },
- {
- "key": "sn",
- "value": "{{t-erp-api-sn}}",
- "type": "text"
- }
- ],
- "body": {
- "mode": "raw",
- "raw": "[\r\n {\r\n \"CUS_NO\": \"CS0003\" // 必须,客户厂商代号,删除该笔客户厂商资料\r\n }\r\n]",
- "options": {
- "raw": {
- "language": "json"
- }
- }
- },
- "url": {
- "raw": "{{t-erp-api-url}}/Cust/DeleteForCust",
- "host": [
- "{{t-erp-api-url}}"
- ],
- "path": [
- "Cust",
- "DeleteForCust"
- ]
- },
- "description": "删除厂商资料"
- },
- "response": []
- }
- ],
- "description": "客户/厂商资料"
- },
- {
- "name": "示例业务:采购订单-采购入库-销售订单-销售出库",
- "item": [
- {
- "name": "新增采购订单",
- "event": [
- {
- "listen": "prerequest",
- "script": {
- "exec": [
- "// 设置当天日期为集合变量,格式:YYYY-MM-DD\r",
- "// 1. 定义补0函数:日/月不足2位时自动补0(核心)\r",
- "function addZero(num) {\r",
- " return num < 10 ? '0' + num : num;\r",
- "}\r",
- "\r",
- "// 2. 获取当前本地时间\r",
- "const now = new Date();\r",
- "\r",
- "// 3. 解析年、月、日(月份+1,日/月调用补0函数)\r",
- "const year = now.getFullYear(); // 年:4位数字(如2026)\r",
- "const month = addZero(now.getMonth() + 1); // 月:补0后(如01/12)\r",
- "const day = addZero(now.getDate()); // 日:补0后(如05/30)\r",
- "\r",
- "// 4. 拼接成YYYY-MM-DD格式\r",
- "const currentDate = `${year}-${month}-${day}`;\r",
- "\r",
- "// 5. 设置为【环境变量】\r",
- "pm.environment.set(\"t-erp-api-current-date\", currentDate);\r",
- "\r",
- "// 可选:打印日志,验证日期是否正确(Postman控制台/Jenkins日志可看)\r",
- "console.log(`✅ 环境变量设置成功:t-erp-api-current-date = ${currentDate}`);"
- ],
- "type": "text/javascript",
- "packages": {},
- "requests": {}
- }
- },
- {
- "listen": "test",
- "script": {
- "exec": [
- "// 1. 解析接口顶层的JSON响应(获取包含Data的原始对象)\r",
- "var resJson = pm.response.json();\r",
- "console.log(\"✅ 接口顶层JSON解析成功\");\r",
- "\r",
- "// 2. 提取Data字段的原始字符串,同时做非空判断\r",
- "var dataRawStr = resJson.Data;\r",
- "if (!dataRawStr) {\r",
- " console.error(\"❌ Data字段为空/不存在,无法解析\");\r",
- " pm.test(\"Data字段非空\", () => pm.expect(dataRawStr).to.not.be.empty);\r",
- " return; // 终止后续脚本\r",
- "}\r",
- "\r",
- "// 3. 核心:解析Data为JSON对象(含异常捕获+清理\\r\\n换行符)\r",
- "var dataJson; // 用于存储解析后的Data JSON对象\r",
- "try {\r",
- " // 清理Data中的\\r\\n(全局替换),可选:可顺带去掉多余空格/\\t\r",
- " var dataCleanStr = dataRawStr.replace(/\\r\\n/g, \"\").replace(/\\s+/g, \" \");\r",
- " // 将清理后的字符串转为JSON对象(核心步骤)\r",
- " dataJson = JSON.parse(dataCleanStr);\r",
- " console.log(\"✅ Data字段成功转为JSON对象\", dataJson);\r",
- "} catch (e) {\r",
- " // 解析失败时打印错误日志+原始Data字符串,方便调试\r",
- " console.error(\"❌ Data解析为JSON失败:\", e.message);\r",
- " console.error(\"❌ Data原始字符串:\", dataRawStr);\r",
- " pm.test(\"Data字段可正常解析为JSON\", () => pm.expect.fail(\"Data格式错误,解析失败\"));\r",
- " return;\r",
- "}\r",
- "\r",
- "// 4. 解析成功后:直接获取Data里的任意字段(按需使用)\r",
- "// 示例:获取你Data中的TF_TABNAME、BIL_NO、BIL_ID等字段\r",
- "var tfTabName = dataJson.TF_TABNAME;\r",
- "var bilNo = dataJson.BIL_NO;\r",
- "var bilId = dataJson.BIL_ID;\r",
- "console.log(`📌 从Data中提取:TF_TABNAME=${tfTabName},BIL_NO=${bilNo},BIL_ID=${bilId}`);\r",
- "\r",
- "// 5. 可选:将解析后的Data JSON对象设置为环境/集合变量,供后续接口使用\r",
- "pm.environment.set(\"t-erp-api-po-bill-no\", bilNo); // 单独存储常用字段(推荐)\r",
- "console.log(\"✅ 解析后的Data字段已存入环境变量\");\r",
- "\r",
- "// 可选:添加测试断言,验证Data中的字段(按需添加)\r",
- "pm.test(\"✅ Data中TF_TABNAME字段存在且正确\", () => {\r",
- " pm.expect(dataJson).to.have.property(\"TF_TABNAME\", \"TF_POS\");\r",
- "});"
- ],
- "type": "text/javascript",
- "packages": {},
- "requests": {}
- }
- }
- ],
- "request": {
- "method": "POST",
- "header": [
- {
- "key": "LoginId",
- "value": "{{t-erp-api-login-id}}",
- "type": "text"
- },
- {
- "key": "sn",
- "value": "{{t-erp-api-sn}}",
- "type": "text"
- }
- ],
- "body": {
- "mode": "raw",
- "raw": "{\n \"HeadData\": { //必须,表头数据\n \"CallId\": \"PO\", //必须,调用的单据识别号,\"PO\":表示采购订单\n \"CusNo\": \"CS0001\", //必须,厂商代号,有来源单或修改时非必须\n \"DepNo\": \"0001\", //非必须,部门代号\n \"SalNo\": \"ZS\", //非必须,业务员代号\n \"EstDate\": \"{{t-erp-api-current-date}}\", //非必须,预交日,单据属性控制是否必填,默认必填\n \"Rem\": \"这是采购订单表头备注\" //非必须,备注\n },\n \"BodyData\": [ //必须,表身数据\n {\n \"PrdNo\": \"YL0001\", //必须,货品代号,有来源单或修改时非必须\n \"WhNo\": \"0001\", //非必须,仓库代号\n \"Qty\": 100, //必须,主数量,有来源单或修改时非必须\n \"Up\": 10, //非必须,主单价\n \"Rem\": \"这是采购订单表身摘要\" //非必须,摘要\n }\n ]\n}",
- "options": {
- "raw": {
- "language": "json"
- }
- }
- },
- "url": {
- "raw": "{{t-erp-api-url}}/Bill/SaveBill",
- "host": [
- "{{t-erp-api-url}}"
- ],
- "path": [
- "Bill",
- "SaveBill"
- ]
- },
- "description": "新增采购订单"
- },
- "response": []
- },
- {
- "name": "新增采购入库单",
- "event": [
- {
- "listen": "prerequest",
- "script": {
- "exec": [
- "// 【集合级前置脚本】设置当天日期为集合变量,格式:YYYY-MM-DD\r",
- "// 1. 定义补0函数:日/月不足2位时自动补0(核心)\r",
- "function addZero(num) {\r",
- " return num < 10 ? '0' + num : num;\r",
- "}\r",
- "\r",
- "// 2. 获取当前本地时间\r",
- "const now = new Date();\r",
- "\r",
- "// 3. 解析年、月、日(月份+1,日/月调用补0函数)\r",
- "const year = now.getFullYear(); // 年:4位数字(如2026)\r",
- "const month = addZero(now.getMonth() + 1); // 月:补0后(如01/12)\r",
- "const day = addZero(now.getDate()); // 日:补0后(如05/30)\r",
- "\r",
- "// 4. 拼接成YYYY-MM-DD格式\r",
- "const currentDate = `${year}-${month}-${day}`;\r",
- "\r",
- "// 5. 设置为【环境变量】\r",
- "pm.environment.set(\"t-erp-api-current-date\", currentDate);\r",
- "\r",
- "// 可选:打印日志,验证日期是否正确(Postman控制台/Jenkins日志可看)\r",
- "console.log(`✅ 环境变量设置成功:t-erp-api-current-date = ${currentDate}`);"
- ],
- "type": "text/javascript",
- "packages": {},
- "requests": {}
- }
- },
- {
- "listen": "test",
- "script": {
- "exec": [
- "// 1. 解析接口顶层的JSON响应(获取包含Data的原始对象)\r",
- "var resJson = pm.response.json();\r",
- "console.log(\"✅ 接口顶层JSON解析成功\");\r",
- "\r",
- "// 2. 提取Data字段的原始字符串,同时做非空判断\r",
- "var dataRawStr = resJson.Data;\r",
- "if (!dataRawStr) {\r",
- " console.error(\"❌ Data字段为空/不存在,无法解析\");\r",
- " pm.test(\"Data字段非空\", () => pm.expect(dataRawStr).to.not.be.empty);\r",
- " return; // 终止后续脚本\r",
- "}\r",
- "\r",
- "// 3. 核心:解析Data为JSON对象(含异常捕获+清理\\r\\n换行符)\r",
- "var dataJson; // 用于存储解析后的Data JSON对象\r",
- "try {\r",
- " // 清理Data中的\\r\\n(全局替换),可选:可顺带去掉多余空格/\\t\r",
- " var dataCleanStr = dataRawStr.replace(/\\r\\n/g, \"\").replace(/\\s+/g, \" \");\r",
- " // 将清理后的字符串转为JSON对象(核心步骤)\r",
- " dataJson = JSON.parse(dataCleanStr);\r",
- " console.log(\"✅ Data字段成功转为JSON对象\", dataJson);\r",
- "} catch (e) {\r",
- " // 解析失败时打印错误日志+原始Data字符串,方便调试\r",
- " console.error(\"❌ Data解析为JSON失败:\", e.message);\r",
- " console.error(\"❌ Data原始字符串:\", dataRawStr);\r",
- " pm.test(\"Data字段可正常解析为JSON\", () => pm.expect.fail(\"Data格式错误,解析失败\"));\r",
- " return;\r",
- "}\r",
- "\r",
- "// 4. 解析成功后:直接获取Data里的任意字段(按需使用)\r",
- "// 示例:获取你Data中的TF_TABNAME、BIL_NO、BIL_ID等字段\r",
- "var tfTabName = dataJson.TF_TABNAME;\r",
- "var bilNo = dataJson.BIL_NO;\r",
- "var bilId = dataJson.BIL_ID;\r",
- "console.log(`📌 从Data中提取:TF_TABNAME=${tfTabName},BIL_NO=${bilNo},BIL_ID=${bilId}`);\r",
- "\r",
- "// 5. 可选:将解析后的Data JSON对象设置为环境/集合变量,供后续接口使用\r",
- "pm.environment.set(\"t-erp-api-pc-bill-no\", bilNo); // 单独存储常用字段(推荐)\r",
- "console.log(\"✅ 解析后的Data字段已存入环境变量\");\r",
- "\r",
- "// 可选:添加测试断言,验证Data中的字段(按需添加)\r",
- "pm.test(\"✅ Data中TF_TABNAME字段存在且正确\", () => {\r",
- " pm.expect(dataJson).to.have.property(\"TF_TABNAME\", \"TF_PSS\");\r",
- "});"
- ],
- "type": "text/javascript",
- "packages": {},
- "requests": {}
- }
- }
- ],
- "request": {
- "method": "POST",
- "header": [
- {
- "key": "LoginId",
- "value": "{{t-erp-api-login-id}}",
- "type": "text"
- },
- {
- "key": "sn",
- "value": "{{t-erp-api-sn}}",
- "type": "text"
- }
- ],
- "body": {
- "mode": "raw",
- "raw": "{\n \"HeadData\": { //必须,表头数据\n \"CallId\": \"PC\", //必须,调用的单据识别号,\"PC\":表示采购入库单\n \"SalNo\": \"ZS\", //非必须,业务员代号\n \"DepNo\": \"0001\" //非必须,部门代号\n },\n \"BodyData\": [ //必须,表身数据\n {\n \"BilId\": \"PO\", //必须,转入来源单识别号,\"PO\":表示采购订单\n \"BilNo\": \"{{t-erp-api-po-bill-no}}\", //必须,转入来源单单号\n \"BilItm\": 1 //必须,转入来源单项次\n }\n ]\n}",
- "options": {
- "raw": {
- "language": "json"
- }
- }
- },
- "url": {
- "raw": "{{t-erp-api-url}}/Bill/SaveBill",
- "host": [
- "{{t-erp-api-url}}"
- ],
- "path": [
- "Bill",
- "SaveBill"
- ]
- },
- "description": "新增采购入库单"
- },
- "response": []
- },
- {
- "name": "货品库存查询(报表)",
- "request": {
- "method": "GET",
- "header": [
- {
- "key": "LoginId",
- "value": "{{t-erp-api-login-id}}",
- "type": "text"
- },
- {
- "key": "PRD_NO",
- "value": "YL0001",
- "type": "text"
- },
- {
- "key": "WH",
- "value": "",
- "type": "text"
- },
- {
- "key": "PRD_LOC",
- "value": "",
- "type": "text"
- },
- {
- "key": "BAT_NO",
- "value": "",
- "type": "text"
- },
- {
- "key": "PRD_MARK",
- "value": "",
- "type": "text"
- },
- {
- "key": "ISGROUPBYWH",
- "value": "T",
- "type": "text"
- },
- {
- "key": "ISGROUPBYPRD_MARK",
- "value": "",
- "type": "text"
- },
- {
- "key": "ISGROUPBYBAT_NO",
- "value": "",
- "type": "text"
- },
- {
- "key": "ISGROUPBYPRD_LOC",
- "value": "",
- "type": "text"
- }
- ],
- "url": {
- "raw": "{{t-erp-api-url}}/TbrECC/GetPrdStockData",
- "host": [
- "{{t-erp-api-url}}"
- ],
- "path": [
- "TbrECC",
- "GetPrdStockData"
- ]
- },
- "description": "货品库存查询(报表)"
- },
- "response": []
- },
- {
- "name": "新增销售订单",
- "event": [
- {
- "listen": "prerequest",
- "script": {
- "exec": [
- "// 【集合级前置脚本】设置当天日期为集合变量,格式:YYYY-MM-DD\r",
- "// 1. 定义补0函数:日/月不足2位时自动补0(核心)\r",
- "function addZero(num) {\r",
- " return num < 10 ? '0' + num : num;\r",
- "}\r",
- "\r",
- "// 2. 获取当前本地时间\r",
- "const now = new Date();\r",
- "\r",
- "// 3. 解析年、月、日(月份+1,日/月调用补0函数)\r",
- "const year = now.getFullYear(); // 年:4位数字(如2026)\r",
- "const month = addZero(now.getMonth() + 1); // 月:补0后(如01/12)\r",
- "const day = addZero(now.getDate()); // 日:补0后(如05/30)\r",
- "\r",
- "// 4. 拼接成YYYY-MM-DD格式\r",
- "const currentDate = `${year}-${month}-${day}`;\r",
- "\r",
- "// 5. 设置为【环境变量】\r",
- "pm.environment.set(\"t-erp-api-current-date\", currentDate);\r",
- "\r",
- "// 可选:打印日志,验证日期是否正确(Postman控制台/Jenkins日志可看)\r",
- "console.log(`✅ 环境变量设置成功:t-erp-api-current-date = ${currentDate}`);"
- ],
- "type": "text/javascript",
- "packages": {},
- "requests": {}
- }
- },
- {
- "listen": "test",
- "script": {
- "exec": [
- "// 1. 解析接口顶层的JSON响应(获取包含Data的原始对象)\r",
- "var resJson = pm.response.json();\r",
- "console.log(\"✅ 接口顶层JSON解析成功\");\r",
- "\r",
- "// 2. 提取Data字段的原始字符串,同时做非空判断\r",
- "var dataRawStr = resJson.Data;\r",
- "if (!dataRawStr) {\r",
- " console.error(\"❌ Data字段为空/不存在,无法解析\");\r",
- " pm.test(\"Data字段非空\", () => pm.expect(dataRawStr).to.not.be.empty);\r",
- " return; // 终止后续脚本\r",
- "}\r",
- "\r",
- "// 3. 核心:解析Data为JSON对象(含异常捕获+清理\\r\\n换行符)\r",
- "var dataJson; // 用于存储解析后的Data JSON对象\r",
- "try {\r",
- " // 清理Data中的\\r\\n(全局替换),可选:可顺带去掉多余空格/\\t\r",
- " var dataCleanStr = dataRawStr.replace(/\\r\\n/g, \"\").replace(/\\s+/g, \" \");\r",
- " // 将清理后的字符串转为JSON对象(核心步骤)\r",
- " dataJson = JSON.parse(dataCleanStr);\r",
- " console.log(\"✅ Data字段成功转为JSON对象\", dataJson);\r",
- "} catch (e) {\r",
- " // 解析失败时打印错误日志+原始Data字符串,方便调试\r",
- " console.error(\"❌ Data解析为JSON失败:\", e.message);\r",
- " console.error(\"❌ Data原始字符串:\", dataRawStr);\r",
- " pm.test(\"Data字段可正常解析为JSON\", () => pm.expect.fail(\"Data格式错误,解析失败\"));\r",
- " return;\r",
- "}\r",
- "\r",
- "// 4. 解析成功后:直接获取Data里的任意字段(按需使用)\r",
- "// 示例:获取你Data中的TF_TABNAME、BIL_NO、BIL_ID等字段\r",
- "var tfTabName = dataJson.TF_TABNAME;\r",
- "var bilNo = dataJson.BIL_NO;\r",
- "var bilId = dataJson.BIL_ID;\r",
- "console.log(`📌 从Data中提取:TF_TABNAME=${tfTabName},BIL_NO=${bilNo},BIL_ID=${bilId}`);\r",
- "\r",
- "// 5. 可选:将解析后的Data JSON对象设置为环境/集合变量,供后续接口使用\r",
- "pm.environment.set(\"t-erp-api-so-bill-no\", bilNo); // 单独存储常用字段(推荐)\r",
- "console.log(\"✅ 解析后的Data字段已存入环境变量\");\r",
- "\r",
- "// 可选:添加测试断言,验证Data中的字段(按需添加)\r",
- "pm.test(\"✅ Data中TF_TABNAME字段存在且正确\", () => {\r",
- " pm.expect(dataJson).to.have.property(\"TF_TABNAME\", \"TF_POS\");\r",
- "});"
- ],
- "type": "text/javascript",
- "packages": {},
- "requests": {}
- }
- }
- ],
- "request": {
- "method": "POST",
- "header": [
- {
- "key": "LoginId",
- "value": "{{t-erp-api-login-id}}",
- "type": "text"
- },
- {
- "key": "sn",
- "value": "{{t-erp-api-sn}}",
- "type": "text"
- }
- ],
- "body": {
- "mode": "raw",
- "raw": "{\n \"HeadData\": { //必须,表头数据\n \"CallId\": \"SO\", //必须,调用的单据识别号,\"PO\":表示采购订单\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\": 100, //必须,主数量,有来源单或修改时非必须\n \"Up\": 100, //非必须,主单价\n \"Rem\": \"这是销售订单表身摘要\" //非必须,摘要\n }\n ]\n}",
- "options": {
- "raw": {
- "language": "json"
- }
- }
- },
- "url": {
- "raw": "{{t-erp-api-url}}/Bill/SaveBill",
- "host": [
- "{{t-erp-api-url}}"
- ],
- "path": [
- "Bill",
- "SaveBill"
- ]
- },
- "description": "新增销售订单"
- },
- "response": []
- },
- {
- "name": "新增销售出库单",
- "event": [
- {
- "listen": "prerequest",
- "script": {
- "exec": [
- "// 【集合级前置脚本】设置当天日期为集合变量,格式:YYYY-MM-DD\r",
- "// 1. 定义补0函数:日/月不足2位时自动补0(核心)\r",
- "function addZero(num) {\r",
- " return num < 10 ? '0' + num : num;\r",
- "}\r",
- "\r",
- "// 2. 获取当前本地时间\r",
- "const now = new Date();\r",
- "\r",
- "// 3. 解析年、月、日(月份+1,日/月调用补0函数)\r",
- "const year = now.getFullYear(); // 年:4位数字(如2026)\r",
- "const month = addZero(now.getMonth() + 1); // 月:补0后(如01/12)\r",
- "const day = addZero(now.getDate()); // 日:补0后(如05/30)\r",
- "\r",
- "// 4. 拼接成YYYY-MM-DD格式\r",
- "const currentDate = `${year}-${month}-${day}`;\r",
- "\r",
- "// 5. 设置为【环境变量】\r",
- "pm.environment.set(\"t-erp-api-current-date\", currentDate);\r",
- "\r",
- "// 可选:打印日志,验证日期是否正确(Postman控制台/Jenkins日志可看)\r",
- "console.log(`✅ 环境变量设置成功:t-erp-api-current-date = ${currentDate}`);"
- ],
- "type": "text/javascript",
- "packages": {},
- "requests": {}
- }
- },
- {
- "listen": "test",
- "script": {
- "exec": [
- "// 1. 解析接口顶层的JSON响应(获取包含Data的原始对象)\r",
- "var resJson = pm.response.json();\r",
- "console.log(\"✅ 接口顶层JSON解析成功\");\r",
- "\r",
- "// 2. 提取Data字段的原始字符串,同时做非空判断\r",
- "var dataRawStr = resJson.Data;\r",
- "if (!dataRawStr) {\r",
- " console.error(\"❌ Data字段为空/不存在,无法解析\");\r",
- " pm.test(\"Data字段非空\", () => pm.expect(dataRawStr).to.not.be.empty);\r",
- " return; // 终止后续脚本\r",
- "}\r",
- "\r",
- "// 3. 核心:解析Data为JSON对象(含异常捕获+清理\\r\\n换行符)\r",
- "var dataJson; // 用于存储解析后的Data JSON对象\r",
- "try {\r",
- " // 清理Data中的\\r\\n(全局替换),可选:可顺带去掉多余空格/\\t\r",
- " var dataCleanStr = dataRawStr.replace(/\\r\\n/g, \"\").replace(/\\s+/g, \" \");\r",
- " // 将清理后的字符串转为JSON对象(核心步骤)\r",
- " dataJson = JSON.parse(dataCleanStr);\r",
- " console.log(\"✅ Data字段成功转为JSON对象\", dataJson);\r",
- "} catch (e) {\r",
- " // 解析失败时打印错误日志+原始Data字符串,方便调试\r",
- " console.error(\"❌ Data解析为JSON失败:\", e.message);\r",
- " console.error(\"❌ Data原始字符串:\", dataRawStr);\r",
- " pm.test(\"Data字段可正常解析为JSON\", () => pm.expect.fail(\"Data格式错误,解析失败\"));\r",
- " return;\r",
- "}\r",
- "\r",
- "// 4. 解析成功后:直接获取Data里的任意字段(按需使用)\r",
- "// 示例:获取你Data中的TF_TABNAME、BIL_NO、BIL_ID等字段\r",
- "var tfTabName = dataJson.TF_TABNAME;\r",
- "var bilNo = dataJson.BIL_NO;\r",
- "var bilId = dataJson.BIL_ID;\r",
- "console.log(`📌 从Data中提取:TF_TABNAME=${tfTabName},BIL_NO=${bilNo},BIL_ID=${bilId}`);\r",
- "\r",
- "// 5. 可选:将解析后的Data JSON对象设置为环境/集合变量,供后续接口使用\r",
- "pm.environment.set(\"t-erp-api-sa-bill-no\", bilNo); // 单独存储常用字段(推荐)\r",
- "console.log(\"✅ 解析后的Data字段已存入环境变量\");\r",
- "\r",
- "// 可选:添加测试断言,验证Data中的字段(按需添加)\r",
- "pm.test(\"✅ Data中TF_TABNAME字段存在且正确\", () => {\r",
- " pm.expect(dataJson).to.have.property(\"TF_TABNAME\", \"TF_PSS\");\r",
- "});"
- ],
- "type": "text/javascript",
- "packages": {},
- "requests": {}
- }
- }
- ],
- "request": {
- "method": "POST",
- "header": [
- {
- "key": "LoginId",
- "value": "{{t-erp-api-login-id}}",
- "type": "text"
- },
- {
- "key": "sn",
- "value": "{{t-erp-api-sn}}",
- "type": "text"
- }
- ],
- "body": {
- "mode": "raw",
- "raw": "{\n \"HeadData\": { //必须,表头数据\n \"CallId\": \"SA\", //必须,调用的单据识别号,\"SA\":表示销售出库单\n \"SalNo\": \"LS\", //非必须,业务员代号\n \"DepNo\": \"0001\" //非必须,部门代号\n },\n \"BodyData\": [ //必须,表身数据\n {\n \"BilId\": \"SO\", //必须,转入来源单识别号,\"PO\":表示采购订单\n \"BilNo\": \"{{t-erp-api-so-bill-no}}\", //必须,转入来源单单号\n \"BilItm\": 1 //必须,转入来源单项次\n }\n ]\n}",
- "options": {
- "raw": {
- "language": "json"
- }
- }
- },
- "url": {
- "raw": "{{t-erp-api-url}}/Bill/SaveBill",
- "host": [
- "{{t-erp-api-url}}"
- ],
- "path": [
- "Bill",
- "SaveBill"
- ]
- },
- "description": "新增销售出库单"
- },
- "response": []
- },
- {
- "name": "货品库存查询(报表)",
- "request": {
- "method": "GET",
- "header": [
- {
- "key": "LoginId",
- "value": "{{t-erp-api-login-id}}",
- "type": "text"
- },
- {
- "key": "PRD_NO",
- "value": "YL0001",
- "type": "text"
- },
- {
- "key": "WH",
- "value": "",
- "type": "text"
- },
- {
- "key": "PRD_LOC",
- "value": "",
- "type": "text"
- },
- {
- "key": "BAT_NO",
- "value": "",
- "type": "text"
- },
- {
- "key": "PRD_MARK",
- "value": "",
- "type": "text"
- },
- {
- "key": "ISGROUPBYWH",
- "value": "T",
- "type": "text"
- },
- {
- "key": "ISGROUPBYPRD_MARK",
- "value": "",
- "type": "text"
- },
- {
- "key": "ISGROUPBYBAT_NO",
- "value": "",
- "type": "text"
- },
- {
- "key": "ISGROUPBYPRD_LOC",
- "value": "",
- "type": "text"
- }
- ],
- "url": {
- "raw": "{{t-erp-api-url}}/TbrECC/GetPrdStockData",
- "host": [
- "{{t-erp-api-url}}"
- ],
- "path": [
- "TbrECC",
- "GetPrdStockData"
- ]
- },
- "description": "货品库存查询(报表)"
- },
- "response": []
- }
- ],
- "description": "采购订单->采购入库->销售订单->销售出库"
- }
- ],
- "event": [
- {
- "listen": "prerequest",
- "script": {
- "type": "text/javascript",
- "packages": {},
- "requests": {},
- "exec": [
- ""
- ]
- }
- },
- {
- "listen": "test",
- "script": {
- "type": "text/javascript",
- "packages": {},
- "requests": {},
- "exec": [
- ""
- ]
- }
- }
- ]
- }
|