This commit is contained in:
2026-08-21 09:20:26 +08:00
parent c9c6d5a0f9
commit 49465315e2
89 changed files with 16413 additions and 1776 deletions
@@ -0,0 +1,37 @@
const assert = require('node:assert/strict');
const fs = require('node:fs');
const path = require('node:path');
const root = path.resolve(__dirname, '..');
const moduleHtml = fs.readFileSync(path.join(root, 'prototype-src/modules/03-overseas-warehouse.html'), 'utf8');
const appJs = fs.readFileSync(path.join(root, 'prototype-src/app.js'), 'utf8');
assert.match(moduleHtml, /onclick="openFbaPalletForm\(\)"/, '新增托盘入口应打开表单');
assert.match(moduleHtml, /id="modal-fba-pallet-form"/, '应提供托盘新增编辑弹框');
['fbp-form-code', 'fbp-form-type', 'fbp-form-volume', 'fbp-form-price', 'fbp-form-warehouse', 'fbp-form-status', 'fbp-form-remark'].forEach((id) => assert.match(moduleHtml, new RegExp(`id="${id}"`), `表单缺少 ${id}`));
assert.match(appJs, /function openFbaPalletForm\(/, '应提供打开托盘表单的方法');
assert.match(appJs, /function saveFbaPalletForm\(/, '应提供保存托盘表单的方法');
assert.match(appJs, /托盘编码已存在/, '保存时应校验重复托盘编码');
assert.match(appJs, /openFbaPalletForm\('\$\{d\.code\}'\)/, '列表编辑操作应传入托盘编码');
assert.match(appJs, /relatedInboundNo:'—',cartonCount:0/, '新增记录应初始化关联信息');
assert.match(moduleHtml, /<th[^>]*>仓库<\/th>/, '托盘列表应展示仓库列');
assert.match(moduleHtml, /id="fbp-form-overseas-warehouse"/, '托盘表单应提供海外仓字段');
assert.match(appJs, /warehouse:'洛杉矶长滩海外仓'/, '托盘示例数据应包含仓库字段');
assert.match(appJs, /d\.warehouse/, '托盘列表应渲染仓库字段');
assert.match(appJs, /fbp-form-overseas-warehouse/, '托盘新增编辑应读写仓库字段');
assert.match(appJs, /id === 'fbp-wh'|fbp-wh/, '托盘列表应支持按仓库筛选');
assert.match(moduleHtml, /<th[^>]*>容积\(m³\)<\/th>\s*<th[^>]*>托盘重量\(kg\)<\/th>/, '托盘重量应在容积后展示');
assert.match(moduleHtml, /<label>托盘重量\(kg\) \*<\/label><input id="fbp-form-weight" type="number" min="0\.01" step="0\.01" required aria-required="true"/, '新增编辑表单应提供必填托盘重量');
const palletDataBlock = appJs.match(/const fbaPalletData = \[([\s\S]*?)\];/);
assert.ok(palletDataBlock, '应定义托盘示例数据');
assert.equal((palletDataBlock[1].match(/weight:\s*\d+(?:\.\d+)?/g) || []).length, 5, '每条托盘示例数据都应包含重量');
assert.match(appJs, /\$\{d\.weight\}/, '托盘列表应渲染重量');
assert.match(appJs, /set\('fbp-form-weight',d\?d\.weight:''\)/, '编辑托盘时应回填重量');
assert.match(appJs, /const weightInput=get\('fbp-form-weight'\)/, '保存时应读取重量');
assert.match(appJs, /!weightInput\|\|!Number\.isFinite\(weight\)\|\|weight<=0/, '重量为空或不大于0时应阻止保存');
assert.match(appJs, /请输入大于0的托盘重量/, '重量校验应提供明确提示');
assert.match(appJs, /const next=\{code,type,warehouse,vol:volume,weight,purchasePrice,fbaWh,status,remark\}/, '新增编辑保存结果应包含重量');
console.log('FBA pallet create/edit checks passed');