diff --git a/AGENTS.md b/AGENTS.md index a679be38..385d7d2c 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -41,6 +41,7 @@ | 登录、会话与双区域 Token | `modules/auth/`、`core/auth/` | 国内 `auth/`、`iam/`;海外请求客户端再读 `shared/api/AGENTS.md` | | 启动与懒加载资源恢复 | `main.ts`、`core/routing/navigationRecovery.ts` | 仅识别动态模块/Chunk 资源过期;30 秒内同目标最多自动恢复一次,存在未保存编辑时必须先确认 | | 工作台与指标 | `modules/dashboard/` | 指标所属模块与服务端,不复制领域契约 | +| FBA 无匹配价格、人工定价 | `modules/inbounds/fee/api.ts` 的 `createManualInboundQuote`、`types.ts`;页面消费沿 `InboundFeePanel.vue` 核对 | `POST /manual-quote` 提交计费重量、体积、单价、原因和 `Idempotency-Key`;Backend `PlatformFbaPricingController.manualQuote` → `FbaPricingService.manualQuote`,权限 `firstleg:inbound:confirm-send-fee`。仅 FBA、已有实际测量且当前价格未命中时允许,客户已确认费用禁止改价;`MANUAL_QUOTE` 快照允许价格记录与版本为空,不伪造价格簿关联。API 回归 `modules/inbounds/fee/api.test.ts`,不能以 API 存在代替页面接入完成 | | PDA版本、APK下载、WGT热更新发布与停发 | `modules/pda-releases/pages/PdaReleasesView.vue`、`modules/pda-releases/api/pdaReleases.ts`、`modules/pda-releases/routes.ts` | 系统菜单 `/system/pda-releases`;列表权限 `platform:pda-release:list`,上传/发布/停发权限 `platform:pda-release:manage`。国内/海外按 `domestic/overseas` 分开查询,上传只创建草稿,发布与停发需确认;管理请求使用国内 HTTP 的 `/platform/v1/files/pda-releases`,后端见 `file/AGENTS.md`,设备安装与重启查对应 PDA 的更新工具 | | 客户、企业审核、客户统计 | `modules/customers/` | `iam/`、`auth/`、`file/`、`firstleg/customerstatistics/`;公司联系电话只作企业联系信息,不修改管理员/成员登录手机号且不要求跨企业唯一。审核必填资质仅营业执照与统一社会信用代码;法人身份证选填,可随资质包提交,也可在已有营业执照后单独补传或替换 | | 供应商、国内整柜 | `modules/suppliers/`、`modules/domestic-containers/` | Backend `warehouse/` 及对应 OpenAPI | diff --git a/docker-compose.production.yml b/docker-compose.production.yml index 580f3a59..96c9dbe6 100644 --- a/docker-compose.production.yml +++ b/docker-compose.production.yml @@ -9,12 +9,16 @@ services: - "127.0.0.1:${HOST_PORT:-9001}:80" environment: CLIENT_WEB_URL: "https://app.buggoglobal.com/" - API_UPSTREAM: "http://gateway:9000" - OVERSEAS_API_UPSTREAM: "http://gateway-overseas:9300" + API_UPSTREAM: "http://gateway-active:9000" + OVERSEAS_API_UPSTREAM: "http://gateway-overseas-active:9300" networks: - infra-network + - routing-network networks: infra-network: external: true name: firstleg-prod-infra-network + routing-network: + external: true + name: firstleg-production-routing diff --git a/scripts/deploy-production.sh b/scripts/deploy-production.sh index 821a7116..c27fb0b1 100644 --- a/scripts/deploy-production.sh +++ b/scripts/deploy-production.sh @@ -59,35 +59,92 @@ compose() { docker compose --project-name "$project_name" -f "$compose_file" "$@" } -container_id="$(compose ps --all --quiet "$service" | head -n 1)" -previous_image="" -if [ -n "$container_id" ]; then - previous_image="$(docker inspect --format '{{.Config.Image}}' "$container_id")" -fi - -if compose up -d --no-deps --pull never "$service" && \ - compose exec -T "$service" wget -qO- http://127.0.0.1/healthz >/dev/null; then - echo "生产前端部署成功: $image_repository:$image_tag" - compose ps "$service" - exit 0 -fi - -echo "生产前端健康检查失败,准备回滚" >&2 -compose logs --tail=100 "$service" >&2 || true -case "$previous_image" in - "$image_repository:"*) ;; - '') echo "首次部署无旧镜像可回滚" >&2; exit 1 ;; - *) echo "旧镜像不属于当前应用,拒绝回滚: $previous_image" >&2; exit 1 ;; +case "$service" in + admin-web) + base_port=9001 + nginx_config=/www/server/panel/vhost/nginx/00-blue-green-admin-web.conf + legacy_container=firstleg-prod-admin-web + ;; + client-web) + base_port=9002 + nginx_config=/www/server/panel/vhost/nginx/00-blue-green-client-web.conf + legacy_container=firstleg-prod-client-web + ;; + *) echo "不支持蓝绿部署的前端服务: $service" >&2; exit 2 ;; esac -previous_tag="${previous_image#"$image_repository:"}" -if [ "$previous_tag" = "$image_tag" ]; then - echo "旧镜像与新镜像一致,无法回滚" >&2 + +state_root=/data/firstleg/deploy/blue-green-state +state_file="$state_root/frontend-$service.active" +routing_network=firstleg-production-routing +mkdir -p "$state_root" +chmod 750 "$state_root" +docker network inspect "$routing_network" >/dev/null 2>&1 || docker network create "$routing_network" >/dev/null + +for pair in gateway-active:firstleg-production-gateway gateway-overseas-active:firstleg-production-gateway-overseas; do + alias_name="${pair%%:*}" + container="${pair#*:}" + if docker inspect "$container" >/dev/null 2>&1; then + docker network inspect "$routing_network" --format '{{json .Containers}}' | grep -q "\"$container\"" \ + || docker network connect --alias "$alias_name" "$routing_network" "$container" + fi +done + +active_slot="" +active_container="" +active_port="" +if [ -s "$state_file" ]; then + IFS='|' read -r active_slot active_container active_port active_image < "$state_file" +elif docker inspect "$legacy_container" >/dev/null 2>&1; then + active_slot=legacy + active_container="$legacy_container" + active_port="$base_port" +fi + +if [ "$active_slot" = blue ]; then target_slot=green; else target_slot=blue; fi +[ "$active_slot" = legacy ] && target_slot=green +if [ "$target_slot" = blue ]; then target_port=$((base_port + 20000)); else target_port=$((base_port + 10000)); fi +candidate="${legacy_container}-${target_slot}" +docker rm -f "$candidate" >/dev/null 2>&1 || true + +if ! compose run -d --no-deps --name "$candidate" \ + -p "127.0.0.1:$target_port:80" "$service" >/dev/null; then + docker rm -f "$candidate" >/dev/null 2>&1 || true exit 1 fi -docker pull "$previous_image" -export IMAGE_TAG="$previous_tag" -compose up -d --no-deps --pull never "$service" -compose exec -T "$service" wget -qO- http://127.0.0.1/healthz >/dev/null || true -echo "已回滚至: $previous_image" >&2 -exit 1 + +healthy=false +elapsed=0 +while [ "$elapsed" -lt 120 ]; do + if docker exec "$candidate" wget -qO- http://127.0.0.1/healthz >/dev/null 2>&1; then + healthy=true + break + fi + sleep 2 + elapsed=$((elapsed + 2)) +done +if [ "$healthy" != true ]; then + docker logs --tail 100 "$candidate" >&2 || true + docker rm -f "$candidate" >/dev/null 2>&1 || true + exit 1 +fi + +backup="$nginx_config.blue-green-backup" +cp -f "$nginx_config" "$backup" +if ! sed -i "s#127\.0\.0\.1:${active_port:-$base_port}#127.0.0.1:$target_port#g" "$nginx_config" \ + || cmp -s "$nginx_config" "$backup" || ! nginx -t || ! nginx -s reload; then + cp -f "$backup" "$nginx_config" + nginx -t && nginx -s reload || true + docker rm -f "$candidate" >/dev/null 2>&1 || true + exit 1 +fi +rm -f "$backup" + +if [ -n "$active_container" ] && docker inspect "$active_container" >/dev/null 2>&1; then + docker stop --time 30 "$active_container" >/dev/null + docker rm "$active_container" >/dev/null +fi +printf '%s|%s|%s|%s\n' "$target_slot" "$candidate" "$target_port" "$image_repository:$image_tag" > "$state_file.tmp" +chmod 640 "$state_file.tmp" +mv -f "$state_file.tmp" "$state_file" +echo "生产前端蓝绿部署成功: service=$service slot=$target_slot port=$target_port image=$image_repository:$image_tag" REMOTE_DEPLOY diff --git a/src/core/navigation/adminNavigation.ts b/src/core/navigation/adminNavigation.ts index 34c738c8..63c0bb50 100644 --- a/src/core/navigation/adminNavigation.ts +++ b/src/core/navigation/adminNavigation.ts @@ -112,6 +112,7 @@ export const adminNavigation: AdminNavigationNode[] = [ children: [ { key: 'last-mile-orders', title: '尾程订单', icon: ClipboardList, path: '/overseas-warehouse/last-mile-orders', permission: 'platform:overseas-warehouse:last-mile-order:list' }, { key: 'fba-inbound-order', title: '入库单', icon: ClipboardList, path: '/overseas-warehouse/inbound-orders', permission: 'platform:overseas-warehouse:inbound-order:list' }, + { key: 'overseas-locations', title: '库位管理', icon: WarehouseIcon, path: '/overseas-warehouse/locations', permission: 'platform:overseas-warehouse:location:list' }, { key: 'fba-dispatch', title: '排车列表', icon: Truck, path: '/overseas-warehouse/dispatches', permission: 'platform:overseas-warehouse:dispatch:list' }, { key: 'fba-outbound', title: '出库单', icon: ClipboardList, path: '/overseas-warehouse/outbounds', permission: 'platform:overseas-warehouse:outbound:list' }, { key: 'fba-delivery', title: '派送单列表', icon: Truck, path: '/overseas-warehouse/delivery-orders', permission: 'platform:overseas-warehouse:delivery:list' }, @@ -170,6 +171,7 @@ export const adminNavigation: AdminNavigationNode[] = [ { key: 'fba-carrier-rates', title: '船期价格表', icon: CircleDollarSign, path: '/first-leg-pricing/carrier-rates', permission: 'firstleg:fba-pricing:rate:view' }, { key: 'vehicle-list', title: '车辆列表', icon: Truck, path: '/overseas-master-data/vehicles', permission: 'platform:overseas-master-data:vehicle:list' }, { key: 'download-center', title: '下载中心', icon: Download, path: '/downloads', permission: 'platform:download:list' }, + { key: 'mojia-sku-sync', title: '一件代发 SKU 同步', icon: Database, path: '/general/mojia-sku-sync', permission: 'platform:mojia-sku-sync:list' }, ], }, { diff --git a/src/deployment/blueGreenDeployment.test.mjs b/src/deployment/blueGreenDeployment.test.mjs new file mode 100644 index 00000000..ab0275c3 --- /dev/null +++ b/src/deployment/blueGreenDeployment.test.mjs @@ -0,0 +1,27 @@ +import assert from 'node:assert/strict' +import { readFile } from 'node:fs/promises' +import test from 'node:test' + +const script = (await readFile(new URL('../../scripts/deploy-production.sh', import.meta.url), 'utf8')) + .replaceAll('\r\n', '\n') + +test('production frontend starts and validates the candidate before switching nginx', () => { + const start = script.indexOf('compose run -d --no-deps --name "$candidate"') + const health = script.indexOf('docker exec "$candidate" wget') + const nginx = script.indexOf('nginx -t || ! nginx -s reload') + const stop = script.indexOf('docker stop --time 30 "$active_container"') + const state = script.indexOf('mv -f "$state_file.tmp" "$state_file"') + assert.ok(start >= 0 && start < health && health < nginx && nginx < stop && stop < state) +}) + +test('production frontend supports both slots and restores nginx on failure', () => { + assert.match(script, /target_port=\$\(\(base_port \+ 20000\)\)/) + assert.match(script, /target_port=\$\(\(base_port \+ 10000\)\)/) + assert.match(script, /00-blue-green-admin-web\.conf/) + assert.match(script, /00-blue-green-client-web\.conf/) + assert.doesNotMatch(script, /nginx_config=\/www\/server\/panel\/vhost\/nginx\/(?:admin|app)\.buggoglobal\.com\.conf/) + assert.match(script, /cp -f "\$nginx_config" "\$backup"/) + assert.match(script, /cp -f "\$backup" "\$nginx_config"/) + assert.match(script, /docker rm -f "\$candidate"/) + assert.match(script, /gateway-active:firstleg-production-gateway/) +}) diff --git a/src/deployment/nginxConfig.test.ts b/src/deployment/nginxConfig.test.ts index c1bc11b2..58d0630d 100644 --- a/src/deployment/nginxConfig.test.ts +++ b/src/deployment/nginxConfig.test.ts @@ -60,7 +60,9 @@ describe('admin nginx deployment config', () => { expect(jenkinsfile).toContain("credentialsId: 'firstleg-production-ssh'") expect(jenkinsfile).toContain('git rev-parse origin/main') expect(productionCompose).toContain('127.0.0.1:${HOST_PORT:-9001}:80') - expect(productionCompose).toContain('API_UPSTREAM: "http://gateway:9000"') + expect(productionCompose).toContain('API_UPSTREAM: "http://gateway-active:9000"') + expect(productionCompose).toContain('OVERSEAS_API_UPSTREAM: "http://gateway-overseas-active:9300"') + expect(productionCompose).toContain('name: firstleg-production-routing') expect(productionCompose).toContain('name: firstleg-prod-infra-network') }) diff --git a/src/modules/iam/pages/RolesView.test.ts b/src/modules/iam/pages/RolesView.test.ts index eb805e05..d1472728 100644 --- a/src/modules/iam/pages/RolesView.test.ts +++ b/src/modules/iam/pages/RolesView.test.ts @@ -104,6 +104,7 @@ describe('RolesView', () => { it('restores saved permission ids after the dialog tree has mounted', () => { expect(rolesSource).toContain('@opened="initializePermissionSelection"') expect(rolesSource).toContain('treeRef.value?.setCheckedKeys([...form.permissionIds])') + expect(rolesSource).not.toContain('{{ data.code }}') expect(rolesSource).not.toContain('nextTick(() =>') }) diff --git a/src/modules/iam/pages/RolesView.vue b/src/modules/iam/pages/RolesView.vue index 3300bfad..26efde9d 100644 --- a/src/modules/iam/pages/RolesView.vue +++ b/src/modules/iam/pages/RolesView.vue @@ -266,7 +266,7 @@ onMounted(loadRoles) - + @@ -279,7 +279,6 @@ onMounted(loadRoles) .role-editor-layout > .role-editor-permissions.density-form-section { min-width: 0; padding: 0 0 0 var(--admin-space-5); border-left: 1px solid var(--cc-border); } .permission-tree { max-height: 380px; overflow-x: hidden; overflow-y: auto; } .permission-node span { min-width: 0; } -.permission-node code { max-width: 58%; white-space: normal; text-align: right; } .permission-node.is-navigation-group span { font-weight: 650; } :global(.role-editor-dialog) { max-height: min(760px, calc(100vh - 32px)); display: flex; flex-direction: column; } :global(.role-editor-dialog .el-dialog__body) { min-height: 0; overflow-y: auto; } diff --git a/src/modules/inbounds/fee/InboundFeePanel.test.ts b/src/modules/inbounds/fee/InboundFeePanel.test.ts index 3930dfb7..c53e01cc 100644 --- a/src/modules/inbounds/fee/InboundFeePanel.test.ts +++ b/src/modules/inbounds/fee/InboundFeePanel.test.ts @@ -381,4 +381,5 @@ describe('InboundFeePanel', () => { expect(document.body.textContent).toContain('系统已刷新最新快照') expect(document.body.textContent).toContain('当前输入仍保留') }) + }) diff --git a/src/modules/inbounds/fee/InboundFeePanel.vue b/src/modules/inbounds/fee/InboundFeePanel.vue index ed9609f0..50f7ce59 100644 --- a/src/modules/inbounds/fee/InboundFeePanel.vue +++ b/src/modules/inbounds/fee/InboundFeePanel.vue @@ -47,6 +47,7 @@ const loadError = ref(null) const adjustmentError = ref(null) const conflictRefreshed = ref(false) const snapshot = ref(null) +const hasLoadedOnce = ref(false) const adjustOpen = ref(false) const trialOpen = ref(false) const trialLoading = ref(false) @@ -183,12 +184,25 @@ async function loadFee(options: { preserveAdjustment?: boolean } = {}) { if (!options.preserveAdjustment && adjustOpen.value) fillAdjustmentForm(result) } catch (error) { if (sequence !== loadSequence) return - snapshot.value = null - emit('loaded', null) - if (error instanceof ApiResponseError && error.code === 'A0404') notFound.value = true - else loadError.value = getApiErrorDetails(error, '费用快照加载失败,请稍后重试') + const hadSnapshot = Boolean(snapshot.value) + if (error instanceof ApiResponseError && error.code === 'A0404') { + notFound.value = !hadSnapshot + if (!hadSnapshot) { + snapshot.value = null + emit('loaded', null) + } + } else { + loadError.value = getApiErrorDetails(error, '费用快照加载失败,请稍后重试') + if (!hadSnapshot) { + snapshot.value = null + emit('loaded', null) + } + } } finally { - if (sequence === loadSequence) loading.value = false + if (sequence === loadSequence) { + loading.value = false + hasLoadedOnce.value = true + } } } @@ -353,6 +367,7 @@ watch( () => { adjustOpen.value = false snapshot.value = null + hasLoadedOnce.value = false void loadFee() }, { immediate: true }, @@ -435,11 +450,18 @@ defineExpose({ reload: loadFee })

需要权限:firstleg:fba-pricing:view

-
+
正在加载费用快照
+ + +

{{ loadError.message }}

+ +
+

{{ loadError.message }}

@@ -597,6 +619,7 @@ defineExpose({ reload: loadFee }) .fee-heading-actions .el-button { margin-left: 0; } .fee-refresh-button .is-spinning { animation: fee-refresh-spin 0.8s linear infinite; } .fee-loading { padding: 20px 0; } +.fee-refresh-error { margin-bottom: 10px; } .inbound-fee-panel :deep(.el-alert p) { margin: 5px 0 0; line-height: 1.55; } .inbound-fee-panel :deep(.el-alert .el-button) { margin-top: 8px; } .empty-note { margin: 0; color: var(--cc-muted); font-size: 12px; } diff --git a/src/modules/inbounds/fee/api.test.ts b/src/modules/inbounds/fee/api.test.ts index 95f7aab9..0725148d 100644 --- a/src/modules/inbounds/fee/api.test.ts +++ b/src/modules/inbounds/fee/api.test.ts @@ -2,6 +2,7 @@ import { beforeEach, describe, expect, it, vi } from 'vitest' import { ApiResponseError, http } from '@/shared/api/http' import { adjustPublishedInboundFee, + createManualInboundQuote, confirmInboundFee, createFeeActionIdempotencyKey, createFeeAdjustmentIdempotencyKey, @@ -69,6 +70,17 @@ describe('inbound fee API', () => { }) }) + it('creates a manual FBA quote through the dedicated fallback endpoint', async () => { + vi.mocked(http.post).mockResolvedValue({ code: '200', message: 'success', data: { ...snapshot, rateCode: 'MANUAL_QUOTE' } }) + const payload = { selectedWeightKg: 62.5, selectedVolumeCbm: 0.384, unitPrice: 12.2, reason: 'FBA价格未维护' } + + await expect(createManualInboundQuote('10001', '88', payload, 'fee-manual-1')) + .resolves.toMatchObject({ rateCode: 'MANUAL_QUOTE' }) + expect(http.post).toHaveBeenCalledWith('/platform/v1/inbounds/88/fees/manual-quote', payload, { + params: { tenantId: '10001' }, headers: { 'Idempotency-Key': 'fee-manual-1' }, + }) + }) + it('preserves backend conflict metadata for stale-version recovery', async () => { vi.mocked(http.put).mockResolvedValue({ code: 'A0409', message: '费用已被其他操作员修改,请刷新后重试', data: null, diff --git a/src/modules/inbounds/fee/api.ts b/src/modules/inbounds/fee/api.ts index 27993cfb..cebe6bf9 100644 --- a/src/modules/inbounds/fee/api.ts +++ b/src/modules/inbounds/fee/api.ts @@ -23,6 +23,16 @@ export async function calculateInboundFee(tenantId: string, inboundId: string, p return unwrapApiResponse(response) } +export async function createManualInboundQuote(tenantId: string, inboundId: string, payload: { + selectedWeightKg: number; selectedVolumeCbm: number; unitPrice: number; reason: string +}, idempotencyKey: string) { + const response = await http.post>( + `${feeBasePath(inboundId)}/manual-quote`, payload, + { params: { tenantId }, headers: { 'Idempotency-Key': idempotencyKey } }, + ) + return unwrapApiResponse(response) +} + async function transitionInboundFee( tenantId: string, inboundId: string, @@ -63,7 +73,7 @@ export function createFeeAdjustmentIdempotencyKey() { return createFeeActionIdempotencyKey('adjust') } -export function createFeeActionIdempotencyKey(action: 'adjust' | 'calculate' | 'confirm' | 'send') { +export function createFeeActionIdempotencyKey(action: 'adjust' | 'calculate' | 'manual' | 'confirm' | 'send') { const uuid = globalThis.crypto?.randomUUID?.() if (uuid) return `fee-${action}-${uuid}` return `fee-${action}-${Date.now()}-${Math.random().toString(36).slice(2, 12)}` diff --git a/src/modules/inbounds/fee/types.ts b/src/modules/inbounds/fee/types.ts index 1e3b814b..f658cd07 100644 --- a/src/modules/inbounds/fee/types.ts +++ b/src/modules/inbounds/fee/types.ts @@ -13,9 +13,9 @@ export interface InboundFeeSnapshot { chargeRuleId: string ruleCode: string chargeRuleVersion: number - carrierRateId: string + carrierRateId: string | null rateCode: string - carrierRateVersion: number + carrierRateVersion: number | null customerId: string customerName: string originWarehouseId: string @@ -45,7 +45,7 @@ export interface InboundFeeSnapshot { additionalAmount: number totalAmount: number currency: string - rateEffectiveFrom: string + rateEffectiveFrom: string | null rateEffectiveTo: string | null calculatedAt: string confirmedAt: string | null diff --git a/src/modules/inbounds/index.ts b/src/modules/inbounds/index.ts index 1aadb9cf..8772c58b 100644 --- a/src/modules/inbounds/index.ts +++ b/src/modules/inbounds/index.ts @@ -8,6 +8,7 @@ export { default as InboundFeePanel } from './fee/InboundFeePanel.vue' export { adjustPublishedInboundFee, calculateInboundFee, + createManualInboundQuote, confirmInboundFee, createFeeAdjustmentIdempotencyKey, createFeeActionIdempotencyKey, diff --git a/src/modules/overseas-warehouse/AGENTS.md b/src/modules/overseas-warehouse/AGENTS.md index b16b216e..dc8cf66e 100644 --- a/src/modules/overseas-warehouse/AGENTS.md +++ b/src/modules/overseas-warehouse/AGENTS.md @@ -17,6 +17,8 @@ | 关键词 | 页面/路由入口 | API 与联查 | |---|---|---| +| 退货预报审核、退货驳回 | `pages/LastMileOrdersView.vue`、`api/lastMileOrders.ts` 的 `reviewReturnOrder` | 尾程订单内 `RETURN_RELABEL + PENDING_REVIEW` 行进入审核,来源退货号取 `sourceOrderNo`;请求 `/platform/v1/last-leg/return-orders/{returnNo}/review` 携带 `X-Customer-Id`,结论 `APPROVE/REJECT`,驳回必填原因。按钮权限入口为 `permissions.ts` 的 `returnOrderReview`;服务端归 `returnreceipt/`,通过后才能签收,不是仓储转运审核或换标完工确认 | +| 换标申请审核、待审核按钮与驳回原因 | `pages/RelabelOrdersView.vue`、`pages/RelabelOrderDetailView.vue`、`api/relabelOrders.ts` | 列表审核动作仅在 `PENDING_REVIEW` 显示,动作选择为审核通过/已驳回,驳回原因必填;审核后不再显示审核按钮。回归见 `pages/RelabelOrdersView.test.ts`、`pages/RelabelOrderDetailView.test.ts`;PDA 完工、客户确认与申请审核分别定位,不混用状态入口 | | 排车车型、托位容量与限重提示 | `dispatchVehicleSpecs.ts`、`components/SmartDispatchDialog.vue`、`pages/DispatchesView.vue` | 预排车型与排车编辑选项共用规格入口:大车 30 托/40000 LB,小车 15 托/10000 LB;超重提示在预排组件,不能把前端提示当作服务端允许提交的依据。回归见 `pages/DispatchesView.test.ts`、`pages/prototypeContract.test.ts` | | 仓储转运审核、通过与驳回 | `pages/LastMileOrdersView.vue`、`components/WarehouseTransferReviewDialog.vue` | `api/warehouseTransfers.ts` 的列表、详情及 `/warehouse-transfers/{transferNo}/review`;审核按钮要求 `permissions.ts` 的 `warehouseTransferApprove` 且行类型为 `WAREHOUSE_TRANSFER`、状态为 `PENDING_REVIEW`。请求携带该行客户范围和转运单号,审核结论为 `APPROVE/REJECT`,驳回原因必填;这是尾程订单内的审核弹框,不是独立审核路由或排车转派送入口 | | 尾程订单控制与柜级入仓计划转换 | `pages/LastMileOrdersView.vue`、`pages/LastMileOrderDetailView.vue` | 柜子工作台按 `sourceContainerBookingId` 消费 `/orders/container-summaries`;服务端分页返回全部稳定来源柜,计划已经齐全的柜仍保留用于接柜仓查询和修改,并按冻结 `plannedArrivalAt` 升序、空值最后排序。详情返回全柜订单且不受列表分页截断;单票手工计划保存后,由服务端在整柜最后一票计划齐全时自动生成并绑定全柜托盘码,一票柜立即生成;`resourcePendingPlanCount` 只表示自动生成异常的重试入口,不是正常人工步骤。柜级确认弹框先调用 `/inbound-plans/container-preview`,按服务端 FBA/一件代发/私人地址分组展示头程已有、海外仓补充和最终托数以及 `readiness/blockers`;散货最终托数不得少于头程已有托盘码,差额连续补码且不阻断流程;一件代发必须严格按不可变头程封托托盘数整体入库,单票表单托数锁定且服务端再次失败关闭校验。前端不计算托数、不逐票建计划、不预占托盘,再把同一 `snapshotVersion/snapshotHash` 原样提交 `/inbound-plans/convert-container`,快照冲突后重新获取预览。服务端只为剩余订单逐票生成独立计划,并为异常遗留的人工计划补齐真实托盘,整批原子且重放不得产生第二批资源。单票完整入库计划、暂扣/解除和八行人工节点均从 `api/lastMileOrders.ts` 提交订单版本与幂等键;预计到仓时间只读展示来源柜冻结值,不进入人工计划请求,服务端按整柜校验并写入同一日期;入仓码只读展示并提交订单冻结值,不允许人工改写。新增暂扣只在 `INBOUND_COMPLETED` 开放,解除暂扣保持可用;暂扣不阻断入库计划,只限制后续排车和出库。人工节点一经保存不得回退柜级节点。转仓候选只取 `../iam/api/platformIam.ts` 的平台公共 `ACTIVE + FBA` 仓主档;Backend `lastleg-service/` | diff --git a/src/modules/overseas-warehouse/api/inboundPlans.ts b/src/modules/overseas-warehouse/api/inboundPlans.ts index 4593bfce..dc9c5d3d 100644 --- a/src/modules/overseas-warehouse/api/inboundPlans.ts +++ b/src/modules/overseas-warehouse/api/inboundPlans.ts @@ -53,6 +53,7 @@ export interface InboundPlanDetailDto { customerName?: string | null orderType?: string | null containerNo?: string | null + overseasWarehouseId?: string | null overseasWarehouseCode?: string | null overseasWarehouseName?: string | null status?: string | null @@ -67,7 +68,7 @@ export interface InboundPlanDetailDto { updatedAt?: string | null remark?: string | null lines: Array<{ id: string; orderId: string; inboundCode?: string | null; fbaWarehouseCode?: string | null; destinationWarehouseId?: string | null; destinationWarehouseCode?: string | null; destinationWarehouseName?: string | null; grossWeightKg?: number | null; netWeightKg?: number | null; volumeCbm?: number | null; requiredPackageCount: number; plannedPalletCount: number }> - pallets: Array<{ id: string; palletNo?: string | null; destinationWarehouseId?: string | null; destinationWarehouseCode?: string | null; destinationWarehouseName?: string | null; capacityCbm?: number | null; allocatedVolumeCbm?: number | null; sequenceNo: number; warehousePalletId?: string | null; warehouseLocationId?: string | null; warehouseResourceLockId?: string | null; assignmentStatus?: string | null; lockedAt?: string | null; actualVolumeCbm?: number | null; actualPackageCount: number }> + pallets: Array<{ id: string; palletNo?: string | null; destinationWarehouseId?: string | null; destinationWarehouseCode?: string | null; destinationWarehouseName?: string | null; capacityCbm?: number | null; allocatedVolumeCbm?: number | null; sequenceNo: number; warehousePalletId?: string | null; warehouseLocationId?: string | null; warehouseLocationCode?: string | null; warehouseLocationType?: string | null; warehouseLocationStatus?: string | null; sharedOverflow?: boolean | null; assignmentStatus?: string | null; lockedAt?: string | null; actualVolumeCbm?: number | null; actualPackageCount: number; version?: number }> allocations: Array<{ lineId: string; palletId: string; palletNo: string; palletOwnerPlanNo: string; palletOwnedByCurrentPlan: boolean; allocatedVolumeCbm?: number | null; plannedPackageCount: number; countedPackageCount: number; pickedPackageCount: number; actualVolumeCbm?: number | null; status?: string | null; version: number }> } @@ -79,3 +80,27 @@ export async function listInboundPlans(query: InboundPlanQuery) { export async function getInboundPlan(planNo: string, customerId: string) { return unwrapApiResponse(await overseasHttp.get, ApiEnvelope>(`/platform/v1/last-leg/inbound-plans/${encodeURIComponent(planNo)}`, { params: { customerId } })) } + +export interface PlatformInventoryMoveRequest { + overseasWarehouseId: string + sourcePalletCode: string + targetLocationCode: string + expectedPalletVersion: number + reason: string + idempotencyKey: string +} + +export interface PlatformInventoryMoveResult { + commandId: string + status: string + canMove?: boolean + blockReason?: string | null + sourceLocationCode?: string | null + targetLocationCode?: string | null + sharedOverflow?: boolean | null +} + +export async function moveInboundPallet(payload: PlatformInventoryMoveRequest) { + const response = await overseasHttp.post, ApiEnvelope>('/platform/v1/last-leg/inventory-moves', payload, { headers: { 'Idempotency-Key': payload.idempotencyKey } }) + return unwrapApiResponse(response) +} diff --git a/src/modules/overseas-warehouse/api/locations.ts b/src/modules/overseas-warehouse/api/locations.ts new file mode 100644 index 00000000..c575f255 --- /dev/null +++ b/src/modules/overseas-warehouse/api/locations.ts @@ -0,0 +1,64 @@ +import { overseasHttp } from '@/shared/api/overseasHttp' +import { unwrapApiResponse, type ApiEnvelope } from '@/shared/api/http' +import { normalizeOverseasPage, type OverseasPagePayload } from './lastMileOrders' + +export type OverseasLocationType = 'VIRTUAL' | 'NORMAL' | 'SHARED_OVERFLOW' +export type OverseasLocationStatus = 'ACTIVE' | 'IDLE' | 'OCCUPIED' | 'INACTIVE' | 'DISABLED' + +export interface OverseasLocationDto { + id: string + warehouseId: string + warehouseCode?: string | null + warehouseName?: string | null + zoneCode: string + zoneName?: string | null + locationCode: string + locationName?: string | null + locationType: OverseasLocationType + sharedOverflow: boolean + status: OverseasLocationStatus + maxLoadKg?: number | string | null + occupiedPalletCount?: number | null + version: number + remark?: string | null + createdAt?: string | null + updatedAt?: string | null +} + +export interface SaveOverseasLocationPayload { + zoneCode: string + locationCode: string + locationType: 'NORMAL' + maxLoadKg: number + status: 'ACTIVE' | 'INACTIVE' + remark?: string | null +} + +export interface OverseasLocationQuery { page?: number; size?: number; zoneCode?: string; keyword?: string; locationType?: OverseasLocationType | ''; status?: OverseasLocationStatus | '' } + +function base(warehouseId: string) { return `/platform/v1/warehouse-admin/${encodeURIComponent(warehouseId)}/locations` } + +export async function listOverseasLocations(warehouseId: string, query: OverseasLocationQuery = {}) { + const response = await overseasHttp.get>, ApiEnvelope>>(base(warehouseId), { params: { page: query.page ?? 1, size: query.size ?? 20, ...query } }) + return normalizeOverseasPage(unwrapApiResponse(response)) +} + +export async function createOverseasLocation(warehouseId: string, payload: SaveOverseasLocationPayload) { + const response = await overseasHttp.post, ApiEnvelope>(base(warehouseId), payload) + return unwrapApiResponse(response) +} + +export async function updateOverseasLocation(warehouseId: string, locationId: string, payload: SaveOverseasLocationPayload & { version: number }) { + const response = await overseasHttp.put, ApiEnvelope>(`${base(warehouseId)}/${encodeURIComponent(locationId)}`, payload) + return unwrapApiResponse(response) +} + +export async function changeOverseasLocationStatus(warehouseId: string, locationId: string, payload: SaveOverseasLocationPayload & { version: number }) { + const response = await overseasHttp.put, ApiEnvelope>(`${base(warehouseId)}/${encodeURIComponent(locationId)}`, payload) + return unwrapApiResponse(response) +} + +export async function deleteOverseasLocation(warehouseId: string, locationId: string, version: number) { + const response = await overseasHttp.delete, ApiEnvelope>(`${base(warehouseId)}/${encodeURIComponent(locationId)}`, { params: { version } }) + return unwrapApiResponse(response) +} diff --git a/src/modules/overseas-warehouse/api/mojiaSkuSync.ts b/src/modules/overseas-warehouse/api/mojiaSkuSync.ts new file mode 100644 index 00000000..31db04d6 --- /dev/null +++ b/src/modules/overseas-warehouse/api/mojiaSkuSync.ts @@ -0,0 +1,104 @@ +import { http, unwrapApiResponse, type ApiEnvelope } from '@/shared/api/http' + +export type MojiaSkuSyncStatus = 'PENDING' | 'SUCCESS' | 'FAILED' + +export interface MojiaSkuSyncRecord { + id: string + skuCode: string + lengthCm: number + widthCm: number + heightCm: number + weightKg: number + imageFileId?: string | null + imageUrl?: string | null + measuredAt?: string | null + receivedAt?: string | null + syncStatus: MojiaSkuSyncStatus + syncFailureCode?: string | null + syncFailureReason?: string | null + lingxingSkuId?: string | null + revision: number + updatedAt?: string | null +} + +export interface MojiaSkuSyncPage { + records: MojiaSkuSyncRecord[] + page: number + size: number + total: number + pages: number +} + +export interface MojiaSkuSyncQuery { + page: number + size: number + skuCode?: string + syncStatus?: MojiaSkuSyncStatus +} + +export interface MojiaSkuSyncConfig { + autoSyncEnabled: boolean +} + +export interface LingxingWarehouseTestResult { + whCode: string + reachable: boolean + matched: boolean + maintained: boolean + productSku?: string | null + barcode?: string | null + length?: number | null + width?: number | null + height?: number | null + weight?: number | null + message: string +} + +export interface LingxingConnectionTestResult { + skuCode: string + warehouses: LingxingWarehouseTestResult[] +} + +const basePath = '/platform/v1/firstleg/mojia-sku-sync' + +export async function listMojiaSkuSync(query: MojiaSkuSyncQuery) { + const response = await http.get, ApiEnvelope>( + basePath, { params: query }, + ) + return unwrapApiResponse(response) +} + +export async function getMojiaSkuSyncConfig() { + const response = await http.get, ApiEnvelope>( + `${basePath}/config`, + ) + return unwrapApiResponse(response) +} + +export async function testLingxingConnection(skuCode: string) { + const response = await http.post, ApiEnvelope>( + `${basePath}/test-connection`, { skuCode }, + ) + return unwrapApiResponse(response) +} + +export async function updateMojiaSkuSync(id: string, data: { + skuCode: string + lengthCm: number + widthCm: number + heightCm: number + weightKg: number + revision: number +}) { + const response = await http.put, ApiEnvelope>( + `${basePath}/${encodeURIComponent(id)}`, data, + ) + return unwrapApiResponse(response) +} + +export async function retryMojiaSkuSync(id: string, revision: number) { + const response = await http.post, ApiEnvelope>( + `${basePath}/${encodeURIComponent(id)}/retry`, { revision }, + ) + return unwrapApiResponse(response) +} diff --git a/src/modules/overseas-warehouse/layoutAcceptance.test.ts b/src/modules/overseas-warehouse/layoutAcceptance.test.ts index 81b0b92f..d3a285d5 100644 --- a/src/modules/overseas-warehouse/layoutAcceptance.test.ts +++ b/src/modules/overseas-warehouse/layoutAcceptance.test.ts @@ -61,6 +61,8 @@ describe('overseas warehouse 1920px layout acceptance', () => { expect(page('DispatchDetailView.vue')).toContain('density-fields') expect(page('DeliveryOrderDetailView.vue')).toContain('density-fields') expect(page('InventoryDetailView.vue')).toContain('density-fields') + expect(page('InventoryDetailView.vue').match(/class="inventory-table-wrap"/g)).toHaveLength(3) + expect(page('InventoryDetailView.vue')).toContain('.inventory-table-wrap { padding:0 var(--admin-space-5) var(--admin-space-4); }') const outbounds = page('OutboundsView.vue') expect(outbounds).toContain('.create-outbound-form :deep(.el-form-item__content > .el-input-number) { width: 100%; }') expect(outbounds).not.toContain('.create-outbound-form :deep(.el-select)') @@ -78,4 +80,18 @@ describe('overseas warehouse 1920px layout acceptance', () => { expect(lastMileDetail).toContain(':title="isSingleLineBusinessField(field) ? String(field.value) : undefined"') expect(lastMileDetail).toContain('.detail-field-value--business { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }') }) + + it('keeps the inbound detail compact and puts pallet facts before appointment metadata', () => { + const inbound = page('InboundOrderDetailView.vue') + expect(inbound).toContain('grid-template-columns: repeat(5, minmax(0, 1fr))') + expect(inbound).toContain('class="section-heading"') + expect(inbound).toContain('.detail-section { min-width: 0; padding: 0;') + expect(inbound).toContain(':deep(.density-detail-header) { border-bottom: 1px solid var(--cc-border); }') + expect(inbound).toContain('.appointment-fields { grid-template-columns:repeat(4,minmax(0,1fr)); }') + expect(inbound).toContain('class="compact-section-heading"') + expect(inbound.match(/class="detail-table-wrap"/g)).toHaveLength(2) + expect(inbound).toContain('.detail-table-wrap { padding:var(--admin-space-3) var(--admin-space-5) var(--admin-space-4); }') + expect(inbound.indexOf('class="detail-section pallet-section"')).toBeLessThan(inbound.indexOf('class="detail-section appointment-section"')) + expect(inbound).not.toContain("fields: ['状态', '预约状态'") + }) }) diff --git a/src/modules/overseas-warehouse/pages/InboundOrderDetailView.vue b/src/modules/overseas-warehouse/pages/InboundOrderDetailView.vue index a041e8dc..5a95845c 100644 --- a/src/modules/overseas-warehouse/pages/InboundOrderDetailView.vue +++ b/src/modules/overseas-warehouse/pages/InboundOrderDetailView.vue @@ -1,12 +1,15 @@ + + + + diff --git a/src/modules/overseas-warehouse/pages/MojiaSkuSyncView.vue b/src/modules/overseas-warehouse/pages/MojiaSkuSyncView.vue new file mode 100644 index 00000000..eecd5f33 --- /dev/null +++ b/src/modules/overseas-warehouse/pages/MojiaSkuSyncView.vue @@ -0,0 +1,212 @@ + + + + + diff --git a/src/modules/overseas-warehouse/pages/prototypeContract.test.ts b/src/modules/overseas-warehouse/pages/prototypeContract.test.ts index 6057670b..66f1bfc5 100644 --- a/src/modules/overseas-warehouse/pages/prototypeContract.test.ts +++ b/src/modules/overseas-warehouse/pages/prototypeContract.test.ts @@ -37,6 +37,7 @@ describe('overseas warehouse first-batch prototype contract', () => { ['PalletsView.vue', 'overseas-pallets-query'], ['CartonsView.vue', 'overseas-cartons-query'], ['ProductsView.vue', 'overseas-products-query'], + ['LocationsView.vue', 'overseas-locations-query'], ]) const keys = [...expected.entries()].map(([fileName, preferenceKey]) => { const value = source(fileName) @@ -127,6 +128,7 @@ describe('overseas warehouse first-batch prototype contract', () => { expect(value).toContain('@back="back"') expect(value).not.toContain('AppDrawer') if (fileName === 'LastMileOrderDetailView.vue') expect(value).toContain('title="新增费用"') + else if (fileName === 'InboundOrderDetailView.vue') expect(value).toContain('移库') else expect(value).not.toContain('AppDialog') } }) @@ -342,10 +344,17 @@ describe('overseas warehouse first-batch prototype contract', () => { expect(value).toContain('(?:)?查看<\/el-button>/) } } + const locations = source('LocationsView.vue') + expect(locations).toContain('海外仓库位管理') + expect(locations).toContain('库位编码') }) it('connects the dispatch prototype detail to the real overseas API', () => { @@ -387,12 +396,12 @@ describe('overseas warehouse first-batch prototype contract', () => { expect(columnKeys('LastMileOrdersView.vue')).toEqual([ 'actions', 'selection', 'orderNo', 'consolidated', 'palletMergeRelation', 'warning', 'orderType', 'rejectedAt', 'inboundCode', 'lxCode', 'owner', 'warehouse', 'transferWarehouse', 'fbaWarehouse', 'containerNo', 'abnormal', 'held', 'pallets', - 'cartons', 'volume', 'quantity', 'volumeWeight', 'portEta', 'portAta', 'warehouseEta', 'inboundOrderNo', + 'cartons', 'cartonDifference', 'volume', 'quantity', 'volumeWeight', 'portEta', 'portAta', 'warehouseEta', 'inboundOrderNo', 'dispatchStatus', 'outboundOrderNo', 'dispatchOrderNo', 'relabelOrderNo', 'relabelStatus', 'status', 'createdAt', 'internalRemark', 'customerRemark', 'warehouseRemark', ]) expect(columnKeys('InboundOrdersView.vue')).toEqual([ - 'actions', 'selection', 'orderNo', 'inboundCode', 'lxCode', 'type', 'warehouse', 'fbaWarehouse', 'owner', 'cartons', 'pickedCartons', 'volume', + 'actions', 'selection', 'orderNo', 'inboundCode', 'lxCode', 'type', 'warehouse', 'fbaWarehouse', 'owner', 'cartons', 'pickedCartons', 'grossWeight', 'netWeight', 'volume', 'pallets', 'assigned', 'mergeAllowed', 'urgent', 'status', 'appointmentStatus', 'dispatchStatus', 'createdAt', ]) expect(columnKeys('InventoryView.vue')).toEqual([ diff --git a/src/modules/overseas-warehouse/permissions.ts b/src/modules/overseas-warehouse/permissions.ts index 4879b9e0..e73a8a7c 100644 --- a/src/modules/overseas-warehouse/permissions.ts +++ b/src/modules/overseas-warehouse/permissions.ts @@ -49,4 +49,7 @@ export const overseasWarehousePermissions = { productList: 'platform:overseas-warehouse:product:list', productCreate: 'platform:overseas-warehouse:product:create', productEdit: 'platform:overseas-warehouse:product:edit', + mojiaSkuSyncList: 'platform:mojia-sku-sync:list', + mojiaSkuSyncEdit: 'platform:mojia-sku-sync:edit', + mojiaSkuSyncRetry: 'platform:mojia-sku-sync:retry', } as const diff --git a/src/modules/overseas-warehouse/routes.ts b/src/modules/overseas-warehouse/routes.ts index 4394c76d..9357f8d2 100644 --- a/src/modules/overseas-warehouse/routes.ts +++ b/src/modules/overseas-warehouse/routes.ts @@ -130,4 +130,16 @@ export const overseasWarehouseRoutes = [ component: () => import('./pages/PalletDetailView.vue'), meta: { title: '托盘详情', description: '查看托盘基础信息与使用信息', permission: permission.palletList, showPageHeading: false }, }, + { + path: 'overseas-warehouse/locations', + name: 'overseas-locations', + component: () => import('./pages/LocationsView.vue'), + meta: { title: '库位管理', description: '维护海外仓普通库位与 A0 共享溢出位', permission: permission.locationList }, + }, + { + path: 'general/mojia-sku-sync', + name: 'mojia-sku-sync', + component: () => import('./pages/MojiaSkuSyncView.vue'), + meta: { title: '一件代发 SKU 同步', description: '查看墨家测量数据并同步领星 SKU 尺寸重量', permission: permission.mojiaSkuSyncList }, + }, ] satisfies RouteRecordRaw[] diff --git a/src/modules/pda-releases/pages/PdaReleasesView.test.ts b/src/modules/pda-releases/pages/PdaReleasesView.test.ts index 25766476..43cd6411 100644 --- a/src/modules/pda-releases/pages/PdaReleasesView.test.ts +++ b/src/modules/pda-releases/pages/PdaReleasesView.test.ts @@ -24,4 +24,12 @@ describe('PDA release workbench', () => { expect(page).toContain('row.current') expect(page).toContain('ElMessageBox.confirm') }) + + it('uses the standard dense list workspace without repeating the route title', () => { + expect(page).toContain('class="surface-panel table-panel pda-release-panel"') + expect(page).toContain('