Compare commits
18
Commits
f851f5667d
..
main
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
2b5525ce49 | ||
|
|
2c98d121ca | ||
|
|
d1eeaab067 | ||
|
|
3ffa706b89 | ||
|
|
22baa5b5c0 | ||
|
|
9f47b1b276 | ||
|
|
7adb97d145 | ||
|
|
24439b15a3 | ||
|
|
7842791c10 | ||
|
|
78893f1144 | ||
|
|
20858dbe33 | ||
|
|
99922bbc34 | ||
|
|
c38a7384aa | ||
|
|
5594e8fa02 | ||
|
|
15b51b6139 | ||
|
|
985cab06b0 | ||
|
|
8b0decbaca | ||
|
|
ffa2b82c73 |
@@ -97,8 +97,8 @@ pnpm typecheck
|
||||
pnpm build
|
||||
```
|
||||
|
||||
- 源码、依赖或构建配置变更至少运行 `pnpm typecheck` 和受影响测试,交付前运行 `pnpm build`;不影响代码、契约或配置的纯文档/索引变更只检查路径、链接及索引合同。
|
||||
- 当前测试使用 Node.js 内置测试运行器,执行 `pnpm test`;项目仍未声明 lint 脚本,不得声称 lint 已通过。
|
||||
- 按 `../../docs/AI工程执行与协作约束.md` 的“验证范围选择”执行;命令表不是每轮清单。文案/纯展示核对差异,小逻辑跑定向测试;类型/签名变化加最小类型检查,公共能力覆盖实际消费者。不因源码修改或交付自动 typecheck、全量测试或构建;构建和全量测试分别说明触发原因,相同编译不重复跑。纯文档/索引只检查路径、链接及索引合同。
|
||||
- 当前测试使用 Node.js 内置测试运行器,局部改动指定受影响测试文件,`pnpm test` 是全量入口;项目未声明 lint 脚本,不得声称 lint 已通过。
|
||||
- 不手工修改 `dist/` 或 `node_modules/`;依赖变更必须同步当前项目依赖清单和锁文件。
|
||||
|
||||
## 全量验收脚本
|
||||
|
||||
@@ -18,7 +18,7 @@
|
||||
| 企业资料、成员与角色 | `src/modules/tenant-management/`、`src/modules/account/` | Backend `iam/`、`auth/`、`file/`;公司联系电话/邮箱是企业资料,不作为登录标识;成员登录手机号可选,修改时同步 Auth、撤销该账号会话并审计。审核必填资质仅营业执照与统一社会信用代码;法人身份证选填,可随营业执照提交,也可在已有营业执照后单独补传或替换。前端角色树到服务端权限的映射统一维护在 `contracts.ts` 的 `FRONTEND_TO_MERCHANT_PERMISSION_CODES`,海外入仓、采购、本土卡车和散板权限必须显式进入该映射 |
|
||||
| 工作台与系统入口 | `src/modules/dashboard/`、`src/modules/system/` | `src/navigation/clientNavigation.ts`、`src/router/index.ts` |
|
||||
| 企业成员消息收件箱 | `src/modules/notifications/` | Backend `iam/src/main/java/com/baiyue/iam/notification/`;列表、详情、已读与未读数契约见 `iam/src/main/resources/openapi/notification-v1.yaml` |
|
||||
| 头程下单、中文批量导入、入仓码关系、箱唛、履约进度与入库费用确认 | `src/modules/first-leg/`;列表与批量入口 `views/FirstLegOrdersView.vue`,模板/导入 API `api/firstLeg.ts`,入仓详情 `components/InboundCodeAssociationDialog.vue`、`api/inboundCodeAssociations.ts`,独立计费重弹框 `components/InboundBillingPanel.vue`、`api/inboundBilling.ts` | 中文 XLSX 模板按当前客户生成地址、全部有效仓库和渠道下拉,最多 50 行,只创建草稿并支持部分/原子导入;导入结果只显示 Excel 行号,不展示内部 `clientRowId`。所有订单行均可进入计费重弹框,尚未推送时展示明确空态;只有具备编辑权限且服务端返回当前 `SENT` 费用时才可二次确认并提交 `expectedFeeVersion` 与幂等键,成功后版本锁定、平台不得再修改。Backend `order/`、`firstleg/`、`warehouse/`,不得用内部 ID 补齐缺失业务编号 |
|
||||
| 头程下单、中文批量导入、入仓码关系、箱唛、履约进度与入库费用确认 | `src/modules/first-leg/`;列表与批量入口 `views/FirstLegOrdersView.vue`,模板/导入 API `api/firstLeg.ts`,入仓详情 `components/InboundCodeAssociationDialog.vue`、`api/inboundCodeAssociations.ts`,费用确认弹框 `components/InboundBillingPanel.vue`、`api/inboundBilling.ts` | 中文 XLSX 模板按当前客户生成地址、全部有效仓库和渠道下拉,最多 50 行,只创建草稿并支持部分/原子导入;导入结果只显示 Excel 行号,不展示内部 `clientRowId`。列表“确认计费重”仅在具备确认权限且服务端 `customerFeeConfirmationRequired=true` 时显示,已确认或未推送费用时隐藏;详情可查看费用;确认提交 `expectedFeeVersion` 与幂等键,成功后版本锁定、平台不得再修改。Backend `order/`、`firstleg/`、`warehouse/`,不得用内部 ID 补齐缺失业务编号 |
|
||||
| 装柜完成后的退税报关资料 | `src/modules/first-leg/views/FirstLegOrdersView.vue` 的“报关资料”、`components/CustomsDocumentsDialog.vue`、`api/customs.ts` | 只显示登录客户在同柜的退税入仓码;报关开始前可上传、替换、调整同一资料覆盖的一个或多个入仓码及删除误传,全部写入携带幂等键和版本;开始后只读冻结资料,整柜完成后才能下载平台回传的一对一完成文件。Backend `firstleg/customs/container/`、`customs-v1.yaml`,二进制归 `file/` |
|
||||
| 统一订单展示 | `src/modules/order-management/` | `src/modules/first-leg/` 与对应后端订单契约 |
|
||||
| 客户财务账单、入仓码联查、收款、未收余额与客户确认 | `src/modules/finance/`;确认与明细入口 `views/FinanceBillsView.vue`、`api/finance.ts`,入仓码通过 `src/modules/first-leg/public.ts` 复用 `InboundCodeAssociationDialog` | Backend `finance/`;账单行只显示服务端 `inboundCode` 并按登录客户查询业务关系,缺失显示“—”,不得回退内部 ID。收款方式由服务端枚举映射中文。出账或已出账调整后为 `PENDING_CONFIRMATION`,客户确认提交登录成员、`expectedVersion` 和幂等键 |
|
||||
|
||||
@@ -54,16 +54,8 @@ test('successful net debit excludes the original estimate and counts only succes
|
||||
assert.equal(presentation.feeStatus(fee('DUTY', null, 100)), '待核定')
|
||||
})
|
||||
|
||||
test('request recovery preserves content and identity while malformed recovery cannot create a replacement', () => {
|
||||
const original = presentation.buildProcurementCreate(draft(), 'Company', 'fixed-key')
|
||||
assert.deepEqual(normalized(submission.restoreProcurementSubmission(JSON.stringify(original))), normalized(original))
|
||||
assert.throws(() => submission.restoreProcurementSubmission('{}'))
|
||||
assert.throws(() => submission.restoreProcurementSubmission(JSON.stringify({ ...original, currency: 'EUR' })))
|
||||
assert.equal(submission.definitelyRejected({ code: 'TIMEOUT' }), false)
|
||||
assert.equal(submission.definitelyRejected({ status: 500 }), false)
|
||||
assert.equal(submission.definitelyRejected({ status: 409 }), false)
|
||||
assert.equal(submission.definitelyRejected({ status: 400 }), true)
|
||||
assert.equal(submission.procurementRequestKey({ getRandomValues: target => { target.set([1, 2, 3, 4]); return target } }), 'proc-00000001000000020000000300000004')
|
||||
test('new requests get unique keys without restoring stored submissions', () => {
|
||||
assert.notEqual(submission.procurementRequestKey(crypto), submission.procurementRequestKey(crypto))
|
||||
})
|
||||
|
||||
class ApiError extends Error { constructor(message, code, status) { super(message); this.code = code; this.status = status } }
|
||||
@@ -109,18 +101,16 @@ test('detail has one in-flight request and an older response cannot overwrite an
|
||||
} finally { harness.dispose() }
|
||||
})
|
||||
|
||||
test('timeout retries the exact original body after reload and does not accept changed form data', async () => {
|
||||
const storage = new Map(), calls = []
|
||||
const first = viewHarness({ createPage: true, storage, api: { createProcurement: async payload => { calls.push(normalized(payload)); throw new ApiError('timeout', 'TIMEOUT') } } })
|
||||
test('timeout releases the form and another click submits the edited current values', async () => {
|
||||
const calls = []
|
||||
const harness = viewHarness({ createPage: true, api: { createProcurement: async payload => { calls.push(normalized(payload)); throw new ApiError('timeout', 'TIMEOUT') } } })
|
||||
try {
|
||||
Object.assign(first.state.form, draft()); await first.state.submit(); assert.equal(calls.length, 1); assert.ok(first.state.pending.value)
|
||||
first.state.form.productName = 'changed'; await first.state.submit(); assert.deepEqual(calls[1], calls[0])
|
||||
} finally { first.dispose() }
|
||||
const recovered = viewHarness({ createPage: true, storage, api: { createProcurement: async payload => { calls.push(normalized(payload)); return { order: { orderNo: 'PO-SAME' } } } } })
|
||||
try {
|
||||
assert.equal(recovered.state.form.productName, 'Test product'); await recovered.state.submit(); assert.deepEqual(calls[2], calls[0])
|
||||
assert.equal(storage.size, 0); assert.equal(recovered.pushes[0].params.orderNo, 'PO-SAME')
|
||||
} finally { recovered.dispose() }
|
||||
Object.assign(harness.state.form, draft()); await harness.state.submit()
|
||||
assert.equal(harness.state.submitting.value, false); assert.equal(harness.storage.size, 0)
|
||||
harness.state.form.productName = 'changed'; await harness.state.submit()
|
||||
assert.equal(calls[1].productName, 'changed'); assert.notEqual(calls[0].idempotencyKey, calls[1].idempotencyKey)
|
||||
assert.equal(harness.state.submitting.value, false)
|
||||
} finally { harness.dispose() }
|
||||
})
|
||||
|
||||
test('submission double-click sends once and definitive validation rejection permits correction', async () => {
|
||||
@@ -129,7 +119,7 @@ test('submission double-click sends once and definitive validation rejection per
|
||||
try {
|
||||
Object.assign(harness.state.form, draft()); const first = harness.state.submit(); await harness.state.submit(); assert.equal(calls, 1)
|
||||
reject(new ApiError('invalid', 'A0422')); await first
|
||||
assert.equal(harness.state.pending.value, null); assert.equal(harness.storage.size, 0)
|
||||
assert.equal(harness.state.submitting.value, false); assert.equal(harness.storage.size, 0)
|
||||
} finally { harness.dispose() }
|
||||
})
|
||||
|
||||
@@ -149,24 +139,18 @@ test('pagination batches one request and switching account clears old rows befor
|
||||
})
|
||||
|
||||
|
||||
test('replay rejection cannot discard an earlier unknown creation outcome', async () => {
|
||||
const calls = []; let attempt = 0
|
||||
const harness = viewHarness({ createPage: true, api: { createProcurement: async payload => {
|
||||
calls.push(normalized(payload)); attempt++
|
||||
if (attempt === 1) throw new ApiError('timeout', 'TIMEOUT')
|
||||
throw new ApiError('permission revoked', 'A0403')
|
||||
} } })
|
||||
test('consecutive timeout and permission failures never persist or freeze a submission', async () => {
|
||||
let attempt = 0
|
||||
const harness = viewHarness({ createPage: true, api: { createProcurement: async () => { throw new ApiError('failed', ++attempt === 1 ? 'TIMEOUT' : 'A0403') } } })
|
||||
try {
|
||||
Object.assign(harness.state.form, draft()); await harness.state.submit()
|
||||
const saved = [...harness.storage.values()][0]; await harness.state.submit()
|
||||
assert.equal([...harness.storage.values()][0], saved); assert.ok(harness.state.pending.value)
|
||||
assert.deepEqual(calls[1], calls[0])
|
||||
Object.assign(harness.state.form, draft()); await harness.state.submit(); await harness.state.submit()
|
||||
assert.equal(attempt, 2); assert.equal(harness.state.submitting.value, false); assert.equal(harness.storage.size, 0)
|
||||
harness.state.form.productName = 'editable'; assert.equal(harness.state.form.productName, 'editable')
|
||||
} finally { harness.dispose() }
|
||||
})
|
||||
|
||||
test('purchase category is optional while its length remains bounded', () => {
|
||||
const payload = presentation.buildProcurementCreate({ ...draft(), purchaseCategory: ' ' }, 'Company', 'key')
|
||||
assert.equal(payload.purchaseCategory, '')
|
||||
assert.equal(submission.restoreProcurementSubmission(JSON.stringify(payload)).purchaseCategory, '')
|
||||
assert.throws(() => presentation.buildProcurementCreate({ ...draft(), purchaseCategory: 'x'.repeat(129) }, 'Company', 'key'), /品类/)
|
||||
})
|
||||
|
||||
@@ -1,23 +1,3 @@
|
||||
import type { ProcurementCreate } from './api/procurement'
|
||||
import { buildProcurementCreate, emptyProcurementDraft } from './procurementPresentation'
|
||||
|
||||
/** Restore the exact request; an unknown result cannot become a new order. */
|
||||
export function restoreProcurementSubmission(raw: string): ProcurementCreate {
|
||||
const saved: unknown = JSON.parse(raw)
|
||||
if (!saved || typeof saved !== 'object' || Array.isArray(saved)) throw new Error('提交记录格式错误')
|
||||
const value = saved as Record<string, unknown>
|
||||
for (const key of ['customerName', 'purchaseCategory', 'productName', 'currency', 'receivingAddress', 'contactName', 'contactPhone', 'idempotencyKey']) if (typeof value[key] !== 'string') throw new Error('提交记录不完整')
|
||||
if (typeof value.purchaseQuantity !== 'number' || typeof value.budgetUnitPrice !== 'number' || !String(value.idempotencyKey).trim() || String(value.idempotencyKey).length > 255) throw new Error('提交记录不完整')
|
||||
for (const key of ['productSpecification', 'productUrl', 'remark']) if (value[key] !== undefined && typeof value[key] !== 'string') throw new Error('提交记录不完整')
|
||||
if (value.currency !== 'CNY' && value.currency !== 'USD') throw new Error('提交记录币种无效')
|
||||
return buildProcurementCreate({ ...emptyProcurementDraft(), purchaseCategory: String(value.purchaseCategory), productName: String(value.productName),
|
||||
productSpecification: String(value.productSpecification || ''), productUrl: String(value.productUrl || ''), purchaseQuantity: String(value.purchaseQuantity),
|
||||
budgetUnitPrice: String(value.budgetUnitPrice), currency: value.currency, receivingAddress: String(value.receivingAddress), contactName: String(value.contactName),
|
||||
contactPhone: String(value.contactPhone), remark: String(value.remark || '') }, String(value.customerName), String(value.idempotencyKey))
|
||||
}
|
||||
export function definitelyRejected(error: { code?: string; status?: number }) {
|
||||
return ['A0400', 'A0401', 'A0403', 'A0422'].includes(error.code || '') || [400, 401, 403, 422].includes(error.status || 0)
|
||||
}
|
||||
export function procurementRequestKey(provider: Pick<Crypto, 'getRandomValues'> & Partial<Pick<Crypto, 'randomUUID'>> = globalThis.crypto) {
|
||||
if (provider.randomUUID) return provider.randomUUID()
|
||||
return `proc-${Array.from(provider.getRandomValues(new Uint32Array(4)), value => value.toString(16).padStart(8, '0')).join('')}`
|
||||
|
||||
@@ -9,9 +9,9 @@ import DataTable, { type DataTableColumn } from '@/components/common/DataTable.v
|
||||
import QueryToolbar, { type QueryField, type QueryModel } from '@/components/common/QueryToolbar.vue'
|
||||
import type { TableAction } from '@/components/common/tableActions'
|
||||
import ProcurementDetailPanel from '../components/ProcurementDetailPanel.vue'
|
||||
import { createProcurement, getProcurement, listProcurements, type ProcurementCreate, type ProcurementDetail, type ProcurementSummary } from '../api/procurement'
|
||||
import { createProcurement, getProcurement, listProcurements, type ProcurementDetail, type ProcurementSummary } from '../api/procurement'
|
||||
import { buildProcurementCreate, dateTime, draftBudgetTotal, emptyProcurementDraft, money, procurementStatuses, statusLabel, statusTone } from '../procurementPresentation'
|
||||
import { definitelyRejected, procurementRequestKey, restoreProcurementSubmission } from '../procurementSubmission'
|
||||
import { procurementRequestKey } from '../procurementSubmission'
|
||||
|
||||
const props = withDefaults(defineProps<{ createPage?: boolean; detailPage?: boolean }>(), { createPage: false, detailPage: false })
|
||||
const auth = useAuthStore(), route = useRoute(), router = useRouter()
|
||||
@@ -20,11 +20,9 @@ const orderNo = computed(() => typeof route.params.orderNo === 'string' ? route.
|
||||
const canCreate = computed(() => auth.hasPermission('merchant:cross-border:procurement:create'))
|
||||
const canList = computed(() => auth.hasPermission('merchant:cross-border:procurement:list'))
|
||||
const identity = computed(() => auth.token ? accessTokenIdentity(auth.token) : null)
|
||||
const storageKey = computed(() => identity.value ? `cc-procurement-submit:${encodeURIComponent(identity.value)}` : null)
|
||||
const companyName = computed(() => auth.profile.tenantName || (auth.user?.tenantName && !/^企业租户 \d+$/.test(auth.user.tenantName) ? auth.user.tenantName : ''))
|
||||
const form = reactive(emptyProcurementDraft())
|
||||
const pending = shallowRef<ProcurementCreate | null>(null)
|
||||
const recoveryError = ref(''), submitError = ref(''), submittedOrder = ref('')
|
||||
const submitError = ref(''), submittedOrder = ref('')
|
||||
const submitting = ref(false), loading = ref(false), error = ref('')
|
||||
const detail = shallowRef<ProcurementDetail | null>(null)
|
||||
const rows = ref<ProcurementSummary[]>([]), total = ref(0)
|
||||
@@ -74,43 +72,22 @@ async function loadDetail() {
|
||||
}
|
||||
function search() { if (query.page === 1) void loadList(); else query.page = 1 }
|
||||
function resetQuery() { const reload = query.page === 1; Object.assign(query, { page: 1, orderNo: '', purchaseCategory: '', productName: '', status: '' }); if (reload) void loadList() }
|
||||
function populate(payload: ProcurementCreate) {
|
||||
Object.assign(form, { purchaseCategory: payload.purchaseCategory, productName: payload.productName, productSpecification: payload.productSpecification || '', productUrl: payload.productUrl || '',
|
||||
purchaseQuantity: String(payload.purchaseQuantity), budgetUnitPrice: String(payload.budgetUnitPrice), currency: payload.currency, receivingAddress: payload.receivingAddress,
|
||||
contactName: payload.contactName, contactPhone: payload.contactPhone, remark: payload.remark || '' })
|
||||
}
|
||||
function restorePending() {
|
||||
pending.value = null; recoveryError.value = ''; submitError.value = ''; submittedOrder.value = ''; Object.assign(form, emptyProcurementDraft())
|
||||
if (!storageKey.value) return
|
||||
try { const saved = sessionStorage.getItem(storageKey.value); if (saved) { pending.value = Object.freeze(restoreProcurementSubmission(saved)); populate(pending.value) } }
|
||||
catch { recoveryError.value = '上次提交记录暂无法恢复,请先在订单列表或通过客服核对提交结果,避免重复下单。' }
|
||||
}
|
||||
function resetForm() { submitError.value = ''; submittedOrder.value = ''; Object.assign(form, emptyProcurementDraft()) }
|
||||
async function submit() {
|
||||
if (submitting.value || !canCreate.value || recoveryError.value || !storageKey.value) return
|
||||
submitError.value = ''; const owner = identity.value, key = storageKey.value; const resuming = Boolean(pending.value)
|
||||
let started = false
|
||||
if (submitting.value || !canCreate.value || !identity.value || submittedOrder.value) return
|
||||
const owner = identity.value; submitting.value = true; submitError.value = ''
|
||||
try {
|
||||
if (!pending.value) {
|
||||
const payload = buildProcurementCreate(form, companyName.value, procurementRequestKey())
|
||||
try { sessionStorage.setItem(key, JSON.stringify(payload)) } catch { throw new Error('浏览器暂无法保留提交信息,请允许会话存储后重试') }
|
||||
pending.value = Object.freeze(payload)
|
||||
}
|
||||
submitting.value = true; started = true
|
||||
const result = await createProcurement(pending.value)
|
||||
sessionStorage.removeItem(key)
|
||||
const result = await createProcurement(buildProcurementCreate(form, companyName.value, procurementRequestKey()))
|
||||
if (!active || owner !== identity.value) return
|
||||
pending.value = null; submittedOrder.value = result.order.orderNo; ElMessage.success('采购订单已提交')
|
||||
submittedOrder.value = result.order.orderNo; ElMessage.success('采购订单已提交')
|
||||
if (canList.value) await router.push({ name: 'cross-border-procurement-detail', params: { orderNo: result.order.orderNo } })
|
||||
} catch (cause) {
|
||||
if (!active || owner !== identity.value) return
|
||||
if (!resuming && cause instanceof ApiError && definitelyRejected(cause)) { sessionStorage.removeItem(key); pending.value = null }
|
||||
submitError.value = started && pending.value ? `${message(cause)}。提交结果尚未确认,请再次确认上次提交结果。` : message(cause)
|
||||
} finally { submitting.value = false }
|
||||
} catch (cause) { if (active && owner === identity.value) submitError.value = message(cause) }
|
||||
finally { submitting.value = false }
|
||||
}
|
||||
watch(() => [mode.value, orderNo.value, query.page, query.size, identity.value], (values, previous) => {
|
||||
if (values[4] !== previous?.[4]) { rows.value = []; total.value = 0 }
|
||||
++requestSequence; inFlight = ''; loading.value = false; error.value = ''; detail.value = null
|
||||
if (mode.value === 'create') restorePending()
|
||||
if (mode.value === 'create') resetForm()
|
||||
else if (mode.value === 'detail') void loadDetail()
|
||||
else void loadList()
|
||||
}, { immediate: true })
|
||||
@@ -140,12 +117,10 @@ onBeforeUnmount(() => { active = false; ++requestSequence })
|
||||
<section v-else class="procurement-create" aria-label="采购下单">
|
||||
<header class="procurement-heading"><div><h2>海外采购下单</h2><p>一单一个商品及规格;预算仅授权样品货款,运费及关税另行核定。</p></div><el-button v-if="canList" @click="returnToList">返回列表</el-button></header>
|
||||
<el-result v-if="!canCreate" icon="warning" title="没有采购下单权限" sub-title="请联系企业管理员配置权限" />
|
||||
<el-result v-else-if="submittedOrder" icon="success" title="采购订单已提交" :sub-title="submittedOrder"><template #extra><el-button @click="restorePending">新建另一单</el-button></template></el-result>
|
||||
<el-result v-else-if="submittedOrder" icon="success" title="采购订单已提交" :sub-title="submittedOrder"><template #extra><el-button @click="resetForm">新建另一单</el-button></template></el-result>
|
||||
<template v-else>
|
||||
<el-alert v-if="recoveryError" :title="recoveryError" type="error" :closable="false" />
|
||||
<el-alert v-else-if="pending" title="已保留本次提交内容。请再次确认上次提交结果,确认前不修改订单信息。" type="warning" :closable="false" />
|
||||
<el-alert v-if="submitError" class="submit-error" :title="submitError" type="error" :closable="false" />
|
||||
<el-form :model="form" label-position="top" :disabled="submitting || Boolean(pending) || Boolean(recoveryError)" @submit.prevent="submit">
|
||||
<el-form :model="form" label-position="top" :disabled="submitting" @submit.prevent="submit">
|
||||
<h3>商品与预算</h3><div class="procurement-form-grid">
|
||||
<el-form-item label="采购品类"><el-input v-model.trim="form.purchaseCategory" maxlength="128" placeholder="" /></el-form-item>
|
||||
<el-form-item label="商品名称" required><el-input v-model.trim="form.productName" maxlength="255" placeholder="" /></el-form-item>
|
||||
@@ -162,7 +137,7 @@ onBeforeUnmount(() => { active = false; ++requestSequence })
|
||||
<el-form-item class="full" label="采购要求"><el-input v-model="form.remark" type="textarea" :rows="3" maxlength="1000" show-word-limit placeholder="" /></el-form-item>
|
||||
</div>
|
||||
</el-form>
|
||||
<footer class="procurement-form-actions"><el-button type="primary" :loading="submitting" :disabled="Boolean(recoveryError) || (!pending && !companyName) || !identity" @click="submit">{{ pending ? '确认上次提交结果' : '提交采购订单' }}</el-button></footer>
|
||||
<footer class="procurement-form-actions"><el-button type="primary" :loading="submitting" :disabled="!companyName || !identity" @click="submit">提交采购订单</el-button></footer>
|
||||
</template>
|
||||
</section>
|
||||
</section>
|
||||
|
||||
@@ -25,7 +25,7 @@
|
||||
|
||||
- 头程订单只用当前正式读写契约;不得扩展 `LEGACY_MANUAL`、旧系统入仓码、C02 不可用回退旧 API、历史部分响应兼容或其他新旧并跑逻辑。触及该链路时同步删除生产分支、类型、文案、Mock 和测试。
|
||||
- 快速下单只创建草稿,不提交、不审核;逐行失败必须回填原因与入仓码,不用内部 ID 代替业务编号。
|
||||
- 入库费用确认携带 `expectedFeeVersion` 与幂等键,金额与冻结状态只认服务端结果;所有订单行都可进入计费重弹框,不按行类型隐藏。
|
||||
- 入库费用确认携带 `expectedFeeVersion` 与幂等键,金额与冻结状态只认服务端结果;列表“确认计费重”仅在具备确认权限且服务端 `customerFeeConfirmationRequired=true` 时显示,已确认或未推送费用的订单不显示;详情保留费用查看入口。
|
||||
- 报关资料在开始后只读冻结资料,未装柜或无资格时不展示入口;`utils/customsEligibility.ts` 是唯一资格判断入口。
|
||||
- 模块间协作只能从本模块 `public.ts` 导入,不穿透其他模块的 `views/` 或内部目录。
|
||||
|
||||
|
||||
@@ -1,20 +0,0 @@
|
||||
import assert from 'node:assert/strict'
|
||||
import test from 'node:test'
|
||||
import { readFileSync } from 'node:fs'
|
||||
import ts from 'typescript'
|
||||
|
||||
test('计费重确认保留大整数来源和原幂等键,只提交预期重量版本', async () => {
|
||||
const calls = []
|
||||
const source = readFileSync(new URL('./chargeableWeights.ts', import.meta.url), 'utf8')
|
||||
const code = ts.transpileModule(source, { compilerOptions: { module: ts.ModuleKind.CommonJS } }).outputText
|
||||
const exports = {}
|
||||
new Function('require', 'exports', code)(() => ({ apiRequest: async request => { calls.push(request); return [] } }), exports)
|
||||
const id = '9223372036854775806'
|
||||
await exports.getChargeableWeights(id)
|
||||
await exports.confirmChargeableWeight({ inboundId: id, fingerprint: 'abc' }, 'original-command')
|
||||
assert.equal(calls[0].url, `/merchant/v1/first-leg/orders/${id}/chargeable-weights`)
|
||||
assert.equal(calls[1].url, `/merchant/v1/first-leg/chargeable-weights/${id}/confirm`)
|
||||
assert.deepEqual(calls[1].headers, { 'Idempotency-Key': 'original-command' })
|
||||
assert.deepEqual(calls[1].data, { expectedFingerprint: 'abc' })
|
||||
assert.equal(calls.some(call => call.url.includes('inbound-billing')), false)
|
||||
})
|
||||
@@ -1,16 +0,0 @@
|
||||
import { apiRequest } from '@/api/http'
|
||||
export interface ChargeableWeight {
|
||||
inboundId: string
|
||||
orderId: string
|
||||
chargeableWeightKg: number
|
||||
fingerprint: string
|
||||
confirmed: boolean
|
||||
confirmedAt: string | null
|
||||
}
|
||||
export function getChargeableWeights(orderId: string) {
|
||||
return apiRequest<ChargeableWeight[]>({ method: 'GET', url: `/merchant/v1/first-leg/orders/${encodeURIComponent(orderId)}/chargeable-weights` })
|
||||
}
|
||||
export function confirmChargeableWeight(weight: ChargeableWeight, key: string) {
|
||||
return apiRequest<ChargeableWeight>({ method: 'POST', url: `/merchant/v1/first-leg/chargeable-weights/${encodeURIComponent(weight.inboundId)}/confirm`,
|
||||
headers: { 'Idempotency-Key': key }, data: { expectedFingerprint: weight.fingerprint } })
|
||||
}
|
||||
@@ -1,48 +0,0 @@
|
||||
import assert from 'node:assert/strict'
|
||||
import test from 'node:test'
|
||||
import { readFileSync } from 'node:fs'
|
||||
import ts from 'typescript'
|
||||
import { ref } from 'vue'
|
||||
|
||||
const flush = async () => { for (let i = 0; i < 8; i++) await Promise.resolve() }
|
||||
function harness(api, props = { orderId: 'one', canConfirm: true }) {
|
||||
let changed, disposed
|
||||
const events = []
|
||||
const source = readFileSync(new URL('./ChargeableWeightDialog.vue', import.meta.url), 'utf8').split('<script setup lang="ts">')[1].split('</script>')[0]
|
||||
const code = ts.transpileModule(source + '\nexports.state = { rows, loading, saving, error, confirm, load };', {
|
||||
compilerOptions: { module: ts.ModuleKind.CommonJS, target: ts.ScriptTarget.ES2022 },
|
||||
}).outputText
|
||||
const exports = {}
|
||||
new Function('require', 'exports', 'defineProps', 'defineEmits', code)(name => {
|
||||
if (name === 'vue') return { ref, watch: (_, callback) => { changed = callback; callback() }, onBeforeUnmount: callback => { disposed = callback } }
|
||||
if (name === 'element-plus') return { ElMessage: { success() {} } }
|
||||
return api
|
||||
}, exports, () => props, () => name => events.push(name))
|
||||
return { ...exports.state, props, change: () => changed(), dispose: () => disposed(), events }
|
||||
}
|
||||
|
||||
test('确认结果未知时重试原命令,成功后回查并通知工作台刷新', async () => {
|
||||
const row = { inboundId: '100', fingerprint: 'weight-v1', chargeableWeightKg: 50, confirmed: false }
|
||||
const commands = []
|
||||
let fail = true
|
||||
const h = harness({ getChargeableWeights: async () => [row], confirmChargeableWeight: async (_, key) => {
|
||||
commands.push(key); if (fail) throw new Error('响应丢失'); row.confirmed = true
|
||||
} })
|
||||
await flush(); await h.confirm(row)
|
||||
assert.equal(h.error.value, '响应丢失'); assert.equal(h.saving.value, '')
|
||||
fail = false; await h.confirm(row)
|
||||
assert.equal(commands[0], commands[1]); assert.deepEqual(h.events, ['confirmed'])
|
||||
assert.equal(h.rows.value[0].confirmed, true); assert.equal(h.saving.value, '')
|
||||
})
|
||||
|
||||
test('切换订单或关闭后丢弃迟到的读取结果,无权限不能确认', async () => {
|
||||
let resolveOld
|
||||
const h = harness({ getChargeableWeights: order => order === 'one' ? new Promise(resolve => { resolveOld = resolve }) : Promise.resolve([]),
|
||||
confirmChargeableWeight: () => { throw new Error('无权限不得写入') } }, { orderId: 'one', canConfirm: false })
|
||||
h.props.orderId = 'two'; h.change(); await flush()
|
||||
resolveOld([{ inboundId: 'old' }]); await flush()
|
||||
assert.deepEqual(h.rows.value, [])
|
||||
await h.confirm({ inboundId: 'old', fingerprint: 'old' })
|
||||
assert.deepEqual(h.events, [])
|
||||
h.dispose()
|
||||
})
|
||||
@@ -1,55 +0,0 @@
|
||||
<script setup lang="ts">
|
||||
import { onBeforeUnmount, ref, watch } from 'vue'
|
||||
import { ElMessage } from 'element-plus'
|
||||
import { getChargeableWeights, confirmChargeableWeight, type ChargeableWeight } from '../api/chargeableWeights'
|
||||
const props = defineProps<{ orderId: string; canConfirm: boolean }>()
|
||||
const emit = defineEmits<{ close: []; confirmed: [] }>()
|
||||
const rows = ref<ChargeableWeight[]>([])
|
||||
const loading = ref(false)
|
||||
const saving = ref('')
|
||||
const error = ref('')
|
||||
const commands = new Map<string, string>()
|
||||
let sequence = 0
|
||||
let confirmationSequence = 0
|
||||
async function load() {
|
||||
const ticket = ++sequence
|
||||
loading.value = true; error.value = ''; rows.value = []
|
||||
try { const data = await getChargeableWeights(props.orderId); if (ticket === sequence) rows.value = data }
|
||||
catch (e) { if (ticket === sequence) error.value = e instanceof Error ? e.message : '计费重加载失败' }
|
||||
finally { if (ticket === sequence) loading.value = false }
|
||||
}
|
||||
async function confirm(row: ChargeableWeight) {
|
||||
if (saving.value || !props.canConfirm) return
|
||||
const ticket = sequence
|
||||
const attempt = ++confirmationSequence
|
||||
const fingerprint = `${row.inboundId}:${row.fingerprint}`
|
||||
const key = commands.get(fingerprint) ?? `weight-${crypto.randomUUID()}`
|
||||
commands.set(fingerprint, key); saving.value = row.inboundId; error.value = ''
|
||||
try {
|
||||
await confirmChargeableWeight(row, key)
|
||||
if (ticket !== sequence) return
|
||||
ElMessage.success('计费重已确认'); emit('confirmed'); await load()
|
||||
} catch (e) { if (ticket === sequence) error.value = e instanceof Error ? e.message : '确认失败,请刷新后重试' }
|
||||
finally { if (attempt === confirmationSequence) saving.value = '' }
|
||||
}
|
||||
watch(() => props.orderId, () => { confirmationSequence++; saving.value = ''; commands.clear(); void load() }, { immediate: true })
|
||||
onBeforeUnmount(() => { sequence++; confirmationSequence++ })
|
||||
</script>
|
||||
<template>
|
||||
<el-dialog :model-value="true" title="确认计费重" width="560px" :close-on-click-modal="false" @close="emit('close')">
|
||||
<el-alert v-if="error" :title="error" type="error" :closable="false" />
|
||||
<el-button v-if="error" :disabled="!!saving" @click="load">重新加载</el-button>
|
||||
<div v-loading="loading">
|
||||
<el-empty v-if="!loading && !error && !rows.length" description="暂无已审核的计费重" />
|
||||
<div v-for="row in rows" :key="row.inboundId" class="weight-row">
|
||||
<span>来源入仓单:{{ row.inboundId }}<br>计费重:{{ row.chargeableWeightKg }} kg</span>
|
||||
<el-tag v-if="row.confirmed" type="success">已确认</el-tag>
|
||||
<el-button v-else-if="canConfirm" type="primary" :disabled="!!saving" :loading="saving === row.inboundId" @click="confirm(row)">确认计费重</el-button>
|
||||
<span v-else>待确认</span>
|
||||
</div>
|
||||
</div>
|
||||
</el-dialog>
|
||||
</template>
|
||||
<style scoped>
|
||||
.weight-row { display: flex; justify-content: space-between; align-items: center; gap: 16px; padding: 12px 0; }
|
||||
</style>
|
||||
@@ -330,7 +330,7 @@ function clearanceResultStatusLabel(value: MerchantClearanceResult) {
|
||||
<template>
|
||||
<el-dialog
|
||||
:model-value="modelValue"
|
||||
class="customs-documents-dialog"
|
||||
class="customs-documents-dialog client-ui"
|
||||
title="退税报关资料"
|
||||
width="920px"
|
||||
append-to-body
|
||||
@@ -448,42 +448,49 @@ function clearanceResultStatusLabel(value: MerchantClearanceResult) {
|
||||
</template>
|
||||
|
||||
<style scoped>
|
||||
:global(.customs-documents-dialog.el-dialog) { display: flex; max-height: 70vh; flex-direction: column; overflow: hidden; }
|
||||
:global(.customs-documents-dialog.el-dialog) { display: flex; max-height: 70vh; flex-direction: column; overflow: hidden; padding: 0; border: 1px solid var(--client-border); border-radius: var(--client-radius); }
|
||||
:global(.customs-documents-dialog .el-dialog__header), :global(.customs-documents-dialog .el-dialog__footer) { flex: 0 0 auto; }
|
||||
:global(.customs-documents-dialog .el-dialog__body) { min-height: 0; flex: 1 1 auto; overflow-y: auto; overscroll-behavior: contain; }
|
||||
:global(.customs-documents-dialog .el-dialog__header) { margin: 0; padding: 18px 48px 18px 20px; border-bottom: 1px solid var(--client-border); }
|
||||
:global(.customs-documents-dialog .el-dialog__title) { color: var(--client-text); font-size: 16px; font-weight: 600; line-height: 24px; }
|
||||
:global(.customs-documents-dialog .el-dialog__headerbtn) { top: 8px; right: 8px; }
|
||||
:global(.customs-documents-dialog .el-dialog__body) { min-height: 0; flex: 1 1 auto; overflow-y: auto; padding: 20px; color: var(--client-text); line-height: 1.6; overscroll-behavior: contain; }
|
||||
:global(.customs-documents-dialog .el-dialog__footer) { padding: 14px 20px; border-top: 1px solid var(--client-border); background: var(--client-header-bg); }
|
||||
.customs-error { display: grid; gap: 10px; justify-items: start; padding: 22px; border: 1px solid #f1b8b8; background: #fff7f7; color: #9f2d2d; }
|
||||
.customs-error span { overflow-wrap: anywhere; font-size: 12px; }
|
||||
.customs-summary { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)) auto; align-items: center; gap: 18px; padding: 16px 18px; border: 1px solid var(--border); background: #f8faf9; }
|
||||
.customs-summary { display: grid; grid-template-columns: minmax(0, 1.6fr) repeat(2, minmax(0, 1fr)) auto; align-items: center; gap: 18px; padding: 16px; border: 1px solid var(--client-border); border-radius: var(--client-radius); background: var(--client-header-bg); }
|
||||
.customs-summary div { min-width: 0; }
|
||||
.customs-summary span { display: block; color: var(--muted); font-size: 11px; }
|
||||
.customs-summary > div > span { display: block; color: var(--muted); font-size: 11px; }
|
||||
.customs-summary strong { display: block; margin-top: 5px; overflow-wrap: anywhere; color: var(--navy); font-size: 14px; }
|
||||
.customs-locked { display: flex; align-items: flex-start; gap: 10px; margin-top: 14px; padding: 13px 15px; border: 1px solid #d5dde1; background: #f5f7f8; color: var(--muted); }
|
||||
.customs-locked strong, .customs-locked span { display: block; }
|
||||
.customs-locked strong { color: var(--navy); font-size: 12px; }
|
||||
.customs-locked span { margin-top: 3px; font-size: 11px; }
|
||||
.customs-section { margin-top: 18px; }
|
||||
.customs-section { margin-top: var(--client-section-gap); padding: 16px; border: 1px solid var(--client-border); border-radius: var(--client-radius); }
|
||||
.customs-section :deep(.el-empty) { padding: 20px 0; }
|
||||
.clearance-result-list { display:grid; gap:10px; }
|
||||
.clearance-result-row { display:grid; grid-template-columns:minmax(0,1fr) auto; gap:6px 14px; padding:12px 14px; border:1px solid var(--border); background:#fbfcfe; }
|
||||
.clearance-result-row strong,.clearance-result-row span { display:block; }
|
||||
.clearance-result-row span { margin-top:4px; color:var(--muted); font-size:11px; }
|
||||
.clearance-result-row p { grid-column:1 / -1; margin:0; color:var(--navy); font-size:12px; }
|
||||
.customs-section-title { display: flex; align-items: flex-start; justify-content: space-between; gap: 18px; margin-bottom: 12px; }
|
||||
.customs-section-title { display: flex; align-items: center; justify-content: space-between; gap: 18px; margin-bottom: 14px; }
|
||||
.customs-section-title h3 { margin: 0; color: var(--navy); font-size: 14px; }
|
||||
.customs-help-heading { display: flex; align-items: center; gap: 4px; }
|
||||
.customs-inbound-options { display: flex; flex-wrap: wrap; gap: 8px 18px; padding: 13px 15px; border: 1px solid var(--border); }
|
||||
.customs-inbound-options { display: flex; flex-wrap: wrap; gap: 8px 18px; padding: 12px 14px; border: 1px solid var(--client-border); border-radius: var(--client-radius); background: var(--client-header-bg); }
|
||||
.customs-inbound-options :deep(.el-checkbox) { margin-right: 0; }
|
||||
.customs-inbound-options :deep(.el-checkbox__label) { white-space: normal; overflow-wrap: anywhere; }
|
||||
.customs-inbound-code { font-family: ui-monospace, SFMono-Regular, Consolas, monospace; }
|
||||
.customs-inbound-options small { margin-left: 7px; color: var(--muted); }
|
||||
.customs-hidden-input { display: none; }
|
||||
.customs-document-list { display: grid; gap: 10px; }
|
||||
.customs-document-card { padding: 14px 16px; border: 1px solid var(--border); }
|
||||
.customs-document-card { padding: 14px 16px; border: 1px solid var(--client-border); border-radius: var(--client-radius); }
|
||||
.customs-document-main { display: flex; align-items: flex-start; gap: 11px; min-width: 0; }
|
||||
.customs-document-main > svg { flex: 0 0 20px; color: var(--primary); }
|
||||
.customs-document-main > div { min-width: 0; }
|
||||
.customs-document-main strong, .customs-document-main span, .customs-document-main small { display: block; overflow-wrap: anywhere; }
|
||||
.customs-document-main strong { color: var(--navy); font-size: 13px; }
|
||||
.customs-document-main strong { color: var(--navy); font-size: 13px; line-height: 1.6; }
|
||||
.customs-document-main span, .customs-document-main small { margin-top: 4px; color: var(--muted); font-size: 11px; }
|
||||
.customs-document-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 2px; margin-top: 8px; }
|
||||
.customs-document-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; align-items: center; gap: 6px 10px; margin-top: 12px; padding-top: 10px; border-top: 1px solid var(--client-border); }
|
||||
.customs-document-actions :deep(.el-button + .el-button) { margin-left: 0; }
|
||||
.customs-scope-editor { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-top: 12px; padding-top: 12px; border-top: 1px dashed var(--border); }
|
||||
.customs-scope-editor :deep(.el-checkbox) { margin-right: 16px; }
|
||||
</style>
|
||||
|
||||
@@ -30,7 +30,7 @@ test('shows the published merchant inbound, measurement details and customer con
|
||||
}
|
||||
assert.match(source, /formatInboundMoney\(props\.data\.latestFee\.totalAmount/)
|
||||
assert.match(source, /formatConversionPrecision\(/)
|
||||
assert.match(source, /确认费用/)
|
||||
assert.match(source, /title="确认计费重"/)
|
||||
assert.match(source, /确认后当前费用版本将锁定/)
|
||||
assert.match(source, /customerConfirmationStatus === 'CONFIRMED'/)
|
||||
assert.match(source, /confirmMerchantInboundFee/)
|
||||
|
||||
@@ -77,7 +77,7 @@ async function confirmFee() {
|
||||
<el-tag :type="props.data.latestFee.customerConfirmationStatus === 'CONFIRMED' ? 'success' : 'warning'" effect="light">
|
||||
{{ props.data.latestFee.customerConfirmationStatus === 'CONFIRMED' ? '客户已确认 · 费用已锁定' : '费用已发布 · 待确认' }}
|
||||
</el-tag>
|
||||
<el-button v-if="props.data.latestFee.customerConfirmationStatus !== 'CONFIRMED' && props.canConfirm" type="primary" @click="feeDialogOpen = true">确认费用</el-button>
|
||||
<el-button v-if="props.data.latestFee.customerConfirmationStatus !== 'CONFIRMED' && props.canConfirm" type="primary" @click="feeDialogOpen = true">确认计费重</el-button>
|
||||
<el-button v-else plain @click="feeDialogOpen = true">查看费用</el-button>
|
||||
</div>
|
||||
</header>
|
||||
@@ -198,7 +198,7 @@ async function confirmFee() {
|
||||
|
||||
</section>
|
||||
|
||||
<el-dialog v-model="feeDialogOpen" class="billing-confirm-dialog" title="确认费用" width="min(1180px, calc(100vw - 40px))" append-to-body @closed="emit('closed')">
|
||||
<el-dialog v-model="feeDialogOpen" class="billing-confirm-dialog" title="确认计费重" width="min(1180px, calc(100vw - 40px))" append-to-body @closed="emit('closed')">
|
||||
<div v-if="props.loading" class="inbound-billing-loading" aria-live="polite" aria-busy="true">
|
||||
<el-skeleton :rows="4" animated />
|
||||
<span class="sr-only">正在加载费用</span>
|
||||
|
||||
@@ -128,41 +128,25 @@ test('cancelled detail summary has no pending overseas synchronization entries',
|
||||
assert.deepEqual(summary, [])
|
||||
})
|
||||
|
||||
test('edit freezes detail version rather than cached list version and replays same key/body after uncertain result', async t => {
|
||||
const h = harness(t)
|
||||
const original = await h.store.loadDraftDetail('one')
|
||||
const session = h.store.beginDraftEdit(original)
|
||||
h.store.orders = [{ ...original, version: 0 }]
|
||||
h.behavior.failWrite = true
|
||||
await assert.rejects(h.store.saveDraft(h.draft, '测试企业', 'one', session), /响应丢失/)
|
||||
const first = h.calls.find(call => call.method === 'PUT')
|
||||
assert.equal(first.data.expectedVersion, 9)
|
||||
assert.equal(first.data.draft.customerRemark, '原草稿')
|
||||
assert.ok(first.headers['Idempotency-Key'])
|
||||
assert.deepEqual(h.calls.map(call => call.method), ['GET', 'PUT'], 'no pre-save version refresh')
|
||||
h.behavior.failWrite = false; h.behavior.version = 10
|
||||
const result = await h.store.saveDraft(h.draft, '测试企业', 'one', session)
|
||||
test('edit preserves the detail version but generates a fresh command after failure', async t => {
|
||||
const h = harness(t), session = h.store.beginDraftEdit(await h.store.loadDraftDetail('one'))
|
||||
h.store.orders = [{ id: 'one', version: 0 }]; h.behavior.failWrite = true
|
||||
await assert.rejects(h.store.saveDraft(h.draft, '客户', 'one', session), /响应丢失/)
|
||||
h.behavior.failWrite = false; h.draft.customerRemark = '已修改'
|
||||
await h.store.saveDraft(h.draft, '客户', 'one', session)
|
||||
const writes = h.calls.filter(call => call.method === 'PUT')
|
||||
assert.deepEqual(writes[1], first)
|
||||
assert.deepEqual(h.calls.map(call => call.method), ['GET', 'PUT', 'GET', 'PUT', 'GET'])
|
||||
assert.equal(result.version, 10)
|
||||
assert.equal(writes[0].data.expectedVersion, 9); assert.equal(writes[1].data.draft.customerRemark, '已修改')
|
||||
assert.notEqual(writes[0].headers['Idempotency-Key'], writes[1].headers['Idempotency-Key'])
|
||||
})
|
||||
|
||||
test('changed retry payload or missing edit session fails closed without issuing a new write', async t => {
|
||||
const h = harness(t)
|
||||
await assert.rejects(h.store.saveDraft(h.draft, '客户', 'one'), /重新打开/)
|
||||
assert.equal(h.calls.length, 0)
|
||||
const session = h.store.beginDraftEdit(await h.store.loadDraftDetail('one'))
|
||||
h.behavior.failWrite = true
|
||||
test('missing edit session is invalid while changed inputs after failure are accepted', async t => {
|
||||
const h = harness(t); await assert.rejects(h.store.saveDraft(h.draft, '客户', 'one'), /重新打开/)
|
||||
const session = h.store.beginDraftEdit(await h.store.loadDraftDetail('one')); h.behavior.failWrite = true
|
||||
await assert.rejects(h.store.saveDraft(h.draft, '客户', 'one', session))
|
||||
h.draft.customerRemark = '不同内容'
|
||||
await assert.rejects(h.store.saveDraft(h.draft, '客户', 'one', session), /重试原内容/)
|
||||
assert.equal(h.calls.filter(call => call.method === 'PUT').length, 1)
|
||||
assert.equal(session.expectedVersion, 9)
|
||||
assert.ok(Object.isFrozen(session))
|
||||
h.draft.customerRemark = '不同内容'; h.behavior.failWrite = false
|
||||
await h.store.saveDraft(h.draft, '客户', 'one', session)
|
||||
assert.equal(h.calls.filter(call => call.method === 'PUT').length, 2)
|
||||
})
|
||||
|
||||
test('read failure after successful edit preserves the same command for retry', async t => {
|
||||
test('read failure after edit does not retain a frozen request', async t => {
|
||||
const h = harness(t)
|
||||
const session = h.store.beginDraftEdit(await h.store.loadDraftDetail('one'))
|
||||
h.behavior.failRead = true
|
||||
@@ -170,28 +154,17 @@ test('read failure after successful edit preserves the same command for retry',
|
||||
h.behavior.failRead = false
|
||||
await h.store.saveDraft(h.draft, '客户', 'one', session)
|
||||
const writes = h.calls.filter(call => call.method === 'PUT')
|
||||
assert.deepEqual(writes[0], writes[1])
|
||||
assert.notEqual(writes[0].headers['Idempotency-Key'], writes[1].headers['Idempotency-Key'])
|
||||
})
|
||||
|
||||
test('cancel forwards version and reason without rejecting submitted orders locally; retry keeps key and body', async t => {
|
||||
const h = harness(t)
|
||||
h.behavior.status = 'SUBMITTED'
|
||||
h.store.orders = [{ id: 'one', status: 'PENDING_REVIEW', version: 0 }]
|
||||
h.behavior.failWrite = true
|
||||
test('cancel submits the current version and reason after a previous failure', async t => {
|
||||
const h = harness(t); h.behavior.status = 'SUBMITTED'; h.behavior.failWrite = true
|
||||
await assert.rejects(h.store.cancelOrder('one', 12, '客户要求取消'), /响应丢失/)
|
||||
const first = h.calls[0]
|
||||
assert.equal(first.method, 'POST')
|
||||
assert.equal(first.url, '/merchant/v1/orders/first-leg/one/cancel')
|
||||
assert.deepEqual(first.data, { expectedVersion: 12, reason: '客户要求取消' })
|
||||
await assert.rejects(h.store.cancelOrder('one', 13, '其他原因'), /原版本和原因/)
|
||||
assert.equal(h.calls.length, 1)
|
||||
h.behavior.failWrite = false
|
||||
await h.store.cancelOrder('one', 12, '客户要求取消')
|
||||
assert.deepEqual(h.calls[2], first)
|
||||
assert.equal(h.calls[1].method, 'GET')
|
||||
assert.equal(h.store.orders.length, 0)
|
||||
h.behavior.failWrite = false; await h.store.cancelOrder('one', 13, '其他原因')
|
||||
const writes = h.calls.filter(call => call.method === 'POST')
|
||||
assert.equal(writes.length, 2); assert.deepEqual(writes[1].data, { expectedVersion: 13, reason: '其他原因' })
|
||||
assert.notEqual(writes[0].headers['Idempotency-Key'], writes[1].headers['Idempotency-Key'])
|
||||
})
|
||||
|
||||
test('cancel requires a detail version and a nonempty reason', async t => {
|
||||
const h = harness(t)
|
||||
await assert.rejects(h.store.cancelOrder('one', undefined, '理由'))
|
||||
@@ -252,24 +225,13 @@ test('cancel UI uses mandatory-reason centered prompt and refreshes after succes
|
||||
assert.deepEqual(h.calls[1], ['cancel', 'one', 12, '客户申请取消'])
|
||||
})
|
||||
|
||||
test('cancel UI keeps an uncertain command for explicit retry, but conflict requires a fresh decision', async () => {
|
||||
const h = cancellationViewHarness()
|
||||
const order = { id: 'one', status: 'DRAFT' }
|
||||
h.behavior.error = new Error('网络无响应')
|
||||
await h.handler(order)
|
||||
assert.equal(h.pendingCancellation.value.expectedVersion, 12)
|
||||
h.behavior.error = null
|
||||
await h.handler(order)
|
||||
assert.equal(h.prompts.length, 1)
|
||||
assert.equal(h.calls.filter(call => call[0] === 'prepare').length, 1)
|
||||
assert.equal(h.calls.filter(call => call[0] === 'confirm').length, 1)
|
||||
assert.deepEqual(h.calls.filter(call => call[0] === 'cancel')[0], h.calls.filter(call => call[0] === 'cancel')[1])
|
||||
h.behavior.error = new h.ApiError()
|
||||
await h.handler(order)
|
||||
assert.equal(h.pendingCancellation.value, undefined)
|
||||
assert.match(h.messages.at(-1), /刷新订单后重新确认/)
|
||||
test('cancel UI releases failure and asks for a current cancellation decision on the next click', async () => {
|
||||
const h = cancellationViewHarness(), order = { id: 'one', status: 'DRAFT' }
|
||||
h.behavior.error = new Error('网络无响应'); await h.handler(order)
|
||||
h.behavior.error = null; await h.handler(order)
|
||||
assert.equal(h.prompts.length, 2); assert.equal(h.calls.filter(call => call[0] === 'prepare').length, 2)
|
||||
assert.equal(h.calls.filter(call => call[0] === 'cancel').length, 2)
|
||||
})
|
||||
|
||||
test('cancel UI blocks unavailable permission and irreversible visible stages before reads or writes', async () => {
|
||||
const h = cancellationViewHarness()
|
||||
h.canCancelOrder.value = false
|
||||
@@ -286,23 +248,14 @@ test('both editor entry points capture detail sessions and both save paths pass
|
||||
assert.equal((view.match(/store\.saveDraft(?:ForSubmission)?\(cloneDraft\(form\), tenantStore\.company\.companyName, editingId\.value, editingSession\.value\)/g) ?? []).length, 2)
|
||||
})
|
||||
|
||||
test('submit reads raw detail version rather than list zero and replays original key and version after timeout', async t => {
|
||||
const h = harness(t)
|
||||
h.store.orders = [{ id: 'one', status: 'DRAFT', version: 0 }]
|
||||
h.behavior.failSubmit = true
|
||||
test('submit uses the current raw version and a fresh key after timeout', async t => {
|
||||
const h = harness(t); h.store.orders = [{id:'one',status:'DRAFT',version:0}]; h.behavior.failSubmit = true
|
||||
await assert.rejects(h.store.submitSaved('one', 'ACTIVE'), /响应丢失/)
|
||||
const first = h.calls[1]
|
||||
assert.equal(first.url, '/merchant/v1/orders/first-leg/one/submit')
|
||||
assert.deepEqual(first.data, { expectedVersion: 9 })
|
||||
assert.ok(first.headers['Idempotency-Key'])
|
||||
h.behavior.version = 10; h.behavior.status = 'SUBMITTED'; h.behavior.failSubmit = false
|
||||
await h.store.submitSaved('one', 'ACTIVE')
|
||||
assert.deepEqual(h.calls[3], first)
|
||||
assert.deepEqual(h.calls.map(call => call.method), ['GET', 'POST', 'GET', 'POST', 'GET'])
|
||||
assert.equal(h.store.hasPendingSubmission('one'), false)
|
||||
h.behavior.version = 10; h.behavior.failSubmit = false; await h.store.submitSaved('one', 'ACTIVE')
|
||||
const writes = h.calls.filter(call => call.url.endsWith('/submit'))
|
||||
assert.deepEqual(writes.map(call => call.data.expectedVersion), [9,10]); assert.notEqual(writes[0].headers['Idempotency-Key'],writes[1].headers['Idempotency-Key'])
|
||||
})
|
||||
|
||||
test('submit refuses missing version or non-draft first decision and preserves command after failed readback', async t => {
|
||||
test('submit validates current status and releases failure after readback', async t => {
|
||||
const h = harness(t)
|
||||
for (const version of [undefined, -1, 1.5]) {
|
||||
h.behavior.version = version
|
||||
@@ -313,49 +266,25 @@ test('submit refuses missing version or non-draft first decision and preserves c
|
||||
assert.ok(h.calls.every(call => call.method === 'GET'))
|
||||
h.behavior.status = 'DRAFT'; h.behavior.failSubmitRead = true
|
||||
await assert.rejects(h.store.submitSaved('one'), /读取失败/)
|
||||
assert.equal(h.store.hasPendingSubmission('one'), true)
|
||||
h.behavior.failRead = false; h.behavior.failSubmitRead = false
|
||||
await h.store.submitSaved('one')
|
||||
const posts = h.calls.filter(call => call.method === 'POST')
|
||||
assert.deepEqual(posts[0], posts[1])
|
||||
assert.notEqual(posts[0].headers['Idempotency-Key'], posts[1].headers['Idempotency-Key'])
|
||||
assert.deepEqual(posts[0].data, { expectedVersion: 0 }, 'raw detail zero is valid')
|
||||
})
|
||||
|
||||
test('save then submit retries without another save and changed form requires an explicit new decision', async t => {
|
||||
const h = harness(t)
|
||||
const session = h.store.beginDraftEdit(await h.store.loadDraftDetail('one'))
|
||||
await h.store.saveDraftForSubmission(h.draft, '客户', 'one', session)
|
||||
h.behavior.failSubmit = true
|
||||
await assert.rejects(h.store.submitSaved('one'))
|
||||
const first = h.calls.find(call => call.url.endsWith('/submit'))
|
||||
await h.store.saveDraftForSubmission(h.draft, '客户', 'one', session)
|
||||
assert.equal(h.calls.filter(call => call.method === 'PUT').length, 1)
|
||||
h.draft.customerRemark = '新决定'
|
||||
await assert.rejects(h.store.saveDraftForSubmission(h.draft, '客户', 'one', session), /重新编辑/)
|
||||
h.behavior.status = 'SUBMITTED'
|
||||
await assert.rejects(h.store.beginNewSubmissionEdit('one'), /不能重新编辑/)
|
||||
assert.equal(h.store.hasPendingSubmission('one'), true)
|
||||
h.behavior.status = 'DRAFT'; h.behavior.version = 12
|
||||
const newSession = await h.store.beginNewSubmissionEdit('one')
|
||||
assert.equal(newSession.expectedVersion, 12)
|
||||
await h.store.saveDraftForSubmission(h.draft, '客户', 'one', newSession)
|
||||
h.behavior.version = 13; h.behavior.failSubmit = false
|
||||
await h.store.submitSaved('one')
|
||||
const posts = h.calls.filter(call => call.url.endsWith('/submit'))
|
||||
assert.notEqual(posts[1].headers['Idempotency-Key'], first.headers['Idempotency-Key'])
|
||||
assert.deepEqual(posts[1].data, { expectedVersion: 13 })
|
||||
test('failed submit leaves the draft editable for a fresh save and submission', async t => {
|
||||
const h = harness(t), session = h.store.beginDraftEdit(await h.store.loadDraftDetail('one'))
|
||||
await h.store.saveDraft(h.draft, '客户', 'one', session); h.behavior.failSubmit = true
|
||||
await assert.rejects(h.store.submitSaved('one')); h.draft.customerRemark = '新内容'
|
||||
await h.store.saveDraft(h.draft, '客户', 'one', session); h.behavior.failSubmit = false
|
||||
await h.store.submitSaved('one'); assert.equal(h.calls.filter(call => call.method === 'PUT').length, 2)
|
||||
})
|
||||
|
||||
test('failed initial submit read does not resave the prepared draft on retry', async t => {
|
||||
const h = harness(t)
|
||||
const session = h.store.beginDraftEdit(await h.store.loadDraftDetail('one'))
|
||||
await h.store.saveDraftForSubmission(h.draft, '客户', 'one', session)
|
||||
h.behavior.failRead = true
|
||||
await assert.rejects(h.store.submitSaved('one'))
|
||||
await h.store.saveDraftForSubmission(h.draft, '客户', 'one', session)
|
||||
assert.equal(h.calls.filter(call => call.method === 'PUT').length, 1)
|
||||
test('failed initial submit read releases the submission guard for the next click', async t => {
|
||||
const h = harness(t); h.behavior.failRead = true; await assert.rejects(h.store.submitSaved('one'))
|
||||
h.behavior.failRead = false; await h.store.submitSaved('one')
|
||||
assert.equal(h.calls.filter(call => call.url.endsWith('/submit')).length, 1)
|
||||
})
|
||||
|
||||
async function submissionViewHarness(t) {
|
||||
const h = harness(t)
|
||||
const source = readFileSync(new URL('../views/FirstLegOrdersView.vue', import.meta.url), 'utf8').match(/<script setup lang="ts">([\s\S]*?)<\/script>/)[1]
|
||||
@@ -377,56 +306,29 @@ async function submissionViewHarness(t) {
|
||||
return { ...h, ...handlers, globals, messages, confirmations }
|
||||
}
|
||||
|
||||
test('real editor submit handler retries original submission without PUT and requires confirmation for changed form', async t => {
|
||||
const h = await submissionViewHarness(t)
|
||||
h.behavior.failSubmit = true
|
||||
await h.submitOrder()
|
||||
await h.submitOrder()
|
||||
assert.equal(h.calls.filter(call => call.method === 'PUT').length, 1)
|
||||
const posts = h.calls.filter(call => call.url.endsWith('/submit'))
|
||||
assert.deepEqual(posts[0], posts[1])
|
||||
h.draft.customerRemark = '修改后的决定'
|
||||
h.behavior.cancelConfirm = true
|
||||
await h.submitOrder()
|
||||
assert.equal(h.confirmations.length, 1)
|
||||
assert.equal(h.calls.filter(call => call.method === 'PUT').length, 1)
|
||||
h.behavior.cancelConfirm = false; h.behavior.failSubmit = false; h.behavior.version = 12
|
||||
await h.submitOrder()
|
||||
assert.equal(h.confirmations.length, 2)
|
||||
assert.equal(h.calls.filter(call => call.method === 'PUT').length, 2)
|
||||
const last = h.calls.filter(call => call.url.endsWith('/submit')).at(-1)
|
||||
assert.deepEqual(last.data, { expectedVersion: 12 })
|
||||
assert.notEqual(last.headers['Idempotency-Key'], posts[0].headers['Idempotency-Key'])
|
||||
assert.equal(h.globals.saving.value, false)
|
||||
test('real editor releases failure and saves current edited input on another click', async t => {
|
||||
const h = await submissionViewHarness(t); h.behavior.failSubmit = true
|
||||
await h.submitOrder(); assert.equal(h.globals.saving.value, false)
|
||||
h.draft.customerRemark = '修改后的决定'; h.behavior.failSubmit = false; await h.submitOrder()
|
||||
const writes = h.calls.filter(call => call.method === 'PUT'), posts = h.calls.filter(call => call.url.endsWith('/submit'))
|
||||
assert.equal(writes.length, 2); assert.equal(writes[1].data.draft.customerRemark, '修改后的决定')
|
||||
assert.notEqual(posts[0].headers['Idempotency-Key'], posts[1].headers['Idempotency-Key']); assert.equal(h.globals.saving.value, false)
|
||||
})
|
||||
|
||||
test('real batch handler retains uncertain IDs across list refresh and retries original commands even if now submitted', async t => {
|
||||
const h = await submissionViewHarness(t)
|
||||
h.behavior.failSubmit = true
|
||||
await h.submitSelectedDraftOrders()
|
||||
assert.deepEqual(h.globals.pendingBatchSubmissionIds.value, ['one'])
|
||||
assert.deepEqual(h.globals.selectedDraftOrders.value, [])
|
||||
h.behavior.failSubmit = false; h.behavior.status = 'SUBMITTED'; h.behavior.version = 10
|
||||
await h.submitSelectedDraftOrders()
|
||||
test('real batch handler uses only current selection after a failed batch', async t => {
|
||||
const h = await submissionViewHarness(t); h.behavior.failSubmit = true
|
||||
await h.submitSelectedDraftOrders(); assert.equal(h.globals.batchSubmitting.value, false)
|
||||
h.behavior.failSubmit = false; await h.submitSelectedDraftOrders()
|
||||
assert.equal(h.calls.filter(call => call.url.endsWith('/submit')).length, 1)
|
||||
h.globals.selectedDraftOrders.value = [{id:'one',version:9}]; await h.submitSelectedDraftOrders()
|
||||
const posts = h.calls.filter(call => call.url.endsWith('/submit'))
|
||||
assert.equal(posts.length, 2)
|
||||
assert.deepEqual(posts[1], posts[0])
|
||||
assert.deepEqual(posts[0].data, { expectedVersion: 9 })
|
||||
assert.deepEqual(h.globals.pendingBatchSubmissionIds.value, [])
|
||||
assert.equal(h.globals.batchSubmitting.value, false)
|
||||
assert.equal(posts.length, 2); assert.notEqual(posts[0].headers['Idempotency-Key'], posts[1].headers['Idempotency-Key'])
|
||||
})
|
||||
|
||||
test('real new-order handler creates once and retries the saved order submission with the original version', async t => {
|
||||
const h = await submissionViewHarness(t)
|
||||
h.globals.editingId.value = undefined; h.globals.editingSession.value = undefined
|
||||
h.behavior.version = 0; h.behavior.failSubmit = true
|
||||
await h.submitOrder()
|
||||
assert.equal(h.globals.editingId.value, 'one')
|
||||
h.behavior.version = 1; h.behavior.status = 'SUBMITTED'; h.behavior.failSubmit = false
|
||||
test('real new-order handler retains the created order and saves current edits after submit failure', async t => {
|
||||
const h = await submissionViewHarness(t); h.globals.editingId.value = undefined; h.globals.editingSession.value = undefined
|
||||
h.behavior.version = 0; h.behavior.failSubmit = true; await h.submitOrder()
|
||||
assert.equal(h.globals.editingId.value, 'one'); h.behavior.failSubmit = false; h.draft.customerRemark = '修改'
|
||||
await h.submitOrder()
|
||||
assert.equal(h.calls.filter(call => call.method === 'POST' && call.url === '/merchant/v1/orders/first-leg').length, 1)
|
||||
assert.equal(h.calls.filter(call => call.method === 'PUT').length, 0)
|
||||
const posts = h.calls.filter(call => call.url.endsWith('/submit'))
|
||||
assert.deepEqual(posts[0], posts[1])
|
||||
assert.deepEqual(posts[0].data, { expectedVersion: 0 })
|
||||
})
|
||||
assert.equal(h.calls.filter(call => call.method === 'PUT').length, 1)
|
||||
assert.equal(h.calls.filter(call => call.url.endsWith('/submit')).length, 2)
|
||||
})
|
||||
@@ -220,7 +220,7 @@ test('only blocks submission when a known company audit status is not active', (
|
||||
})
|
||||
|
||||
test('uses the versioned merchant cancellation contract', () => {
|
||||
assert.match(storeSource, /cancelMerchantFirstLegOrder\(id, pending\.payload, pending\.key\)/)
|
||||
assert.match(storeSource, /cancelMerchantFirstLegOrder\(id, payload, createIdempotencyKey\(/)
|
||||
assert.match(apiSource, /cancelMerchantFirstLegOrder\(id: number \| string, payload: \{ expectedVersion: number; reason: string \}, idempotencyKey: string\)/)
|
||||
})
|
||||
|
||||
@@ -231,8 +231,8 @@ test('sends an idempotency key for create and submit writes', () => {
|
||||
assert.match(apiSource, /createMerchantFirstLegOrderBatch\(items: MerchantBatchDraftItem\[\], idempotencyKey: string\)/)
|
||||
assert.match(apiSource, /headers: \{ 'Idempotency-Key': idempotencyKey \}/)
|
||||
assert.match(storeSource, /createMerchantFirstLegOrderBatch\(items, idempotencyKey\)/)
|
||||
assert.match(storeSource, /pendingSubmissions\.get\(id\)/)
|
||||
assert.match(storeSource, /submitMerchantFirstLegOrder\(id, pending\.payload, pending\.key\)/)
|
||||
assert.doesNotMatch(storeSource, /pendingSubmissions|pendingEdits|pendingCancellation/)
|
||||
assert.match(storeSource, /submitMerchantFirstLegOrder\(id, \{ expectedVersion: order\.version \}, createIdempotencyKey\(/)
|
||||
})
|
||||
|
||||
test('does not expose the contradictory backend rejected state in the client model', () => {
|
||||
|
||||
@@ -404,11 +404,7 @@ export const useFirstLegOrdersStore = defineStore('client-first-leg-orders', ()
|
||||
const orderProgress = ref<Record<string, MerchantOrderProgress>>({})
|
||||
const queryChannelNames = ref<string[]>([])
|
||||
let listRequest = 0
|
||||
const pendingSubmissions = new Map<string, { key: string; payload: { expectedVersion: number } }>()
|
||||
const submissionForms = new Map<string, { snapshot: string; order: FirstLegOrder }>()
|
||||
const submittingIds = new Set<string>()
|
||||
const pendingEdits = new WeakMap<DraftEditSession, { key: string; payload: { expectedVersion: number; draft: FirstLegOrderSaveRequest } }>()
|
||||
const pendingCancellations = new Map<string, { key: string; payload: { expectedVersion: number; reason: string } }>()
|
||||
|
||||
function beginDraftEdit(detail: FirstLegOrder): DraftEditSession {
|
||||
if (!canClientEditFirstLegOrder(detail.status) || !Number.isSafeInteger(detail.version) || detail.version < 0) throw new Error('请重新打开草稿详情后编辑')
|
||||
@@ -534,22 +530,12 @@ export const useFirstLegOrdersStore = defineStore('client-first-leg-orders', ()
|
||||
}
|
||||
|
||||
async function saveDraft(draft: FirstLegOrderDraft, customerName: string, id?: string, editSession?: DraftEditSession) {
|
||||
if (hasPendingSubmission(id)) throw new Error('上次提交结果未确认,请重试原提交,或确认重新编辑后再保存')
|
||||
const warehouse = prepareDraftForSave(draft, warehouses.value)
|
||||
if (id) {
|
||||
if (!editSession || editSession.orderId !== id) throw new Error('请重新打开草稿详情后编辑')
|
||||
const payload = { expectedVersion: editSession.expectedVersion, draft: savePayload(draft, warehouse, customerName) }
|
||||
let pending = pendingEdits.get(editSession)
|
||||
if (pending && JSON.stringify(pending.payload) !== JSON.stringify(payload)) throw new Error('上次保存结果未确认,请重试原内容,或重新打开详情后编辑')
|
||||
// Observe an uncertain previous outcome without replacing its frozen version.
|
||||
if (pending) await getMerchantFirstLegOrder(id)
|
||||
if (!pending) {
|
||||
pending = { key: createIdempotencyKey(`first-leg-edit-${id}`), payload: JSON.parse(JSON.stringify(payload)) }
|
||||
pendingEdits.set(editSession, pending)
|
||||
}
|
||||
await updateMerchantFirstLegOrder(id, pending.payload, pending.key)
|
||||
await updateMerchantFirstLegOrder(id, payload, createIdempotencyKey(`first-leg-edit-${id}`))
|
||||
const saved = await loadOrderAggregate(id)
|
||||
pendingEdits.delete(editSession)
|
||||
return saved
|
||||
}
|
||||
const createdId = await createMerchantFirstLegOrder(savePayload(draft, warehouse, customerName))
|
||||
@@ -559,15 +545,7 @@ export const useFirstLegOrdersStore = defineStore('client-first-leg-orders', ()
|
||||
async function cancelOrder(id: string, expectedVersion: number, reason: string) {
|
||||
if (!Number.isSafeInteger(expectedVersion) || expectedVersion < 0 || !reason.trim() || reason.trim().length > 500) throw new Error('取消订单需要详情版本及 1–500 字取消原因')
|
||||
const payload = { expectedVersion, reason: reason.trim() }
|
||||
let pending = pendingCancellations.get(id)
|
||||
if (pending && JSON.stringify(pending.payload) !== JSON.stringify(payload)) throw new Error('上次取消结果未确认,请使用原版本和原因重试')
|
||||
if (pending) await getMerchantFirstLegOrder(id)
|
||||
if (!pending) {
|
||||
pending = { key: createIdempotencyKey(`first-leg-cancel-${id}`), payload }
|
||||
pendingCancellations.set(id, pending)
|
||||
}
|
||||
await cancelMerchantFirstLegOrder(id, pending.payload, pending.key)
|
||||
pendingCancellations.delete(id)
|
||||
await cancelMerchantFirstLegOrder(id, payload, createIdempotencyKey(`first-leg-cancel-${id}`))
|
||||
orders.value = orders.value.filter(order => order.id !== id)
|
||||
}
|
||||
|
||||
@@ -576,7 +554,6 @@ export const useFirstLegOrdersStore = defineStore('client-first-leg-orders', ()
|
||||
const labels: Record<string, string> = { DRAFT: '草稿', SUBMITTED: '审核中', APPROVED: '已审核', ACCEPTED: '已接单', REJECTED: '已退回' }
|
||||
if (!Object.hasOwn(labels, order.status)) throw new Error('当前订单状态不允许取消,请刷新订单查看最新进度')
|
||||
if (!Number.isSafeInteger(order.version) || order.version < 0) throw new Error('订单版本缺失,请重新加载详情')
|
||||
pendingCancellations.delete(id)
|
||||
return { id, expectedVersion: order.version, businessNo: order.orderNo || order.inboundCode || '—', statusLabel: labels[order.status] }
|
||||
}
|
||||
|
||||
@@ -597,55 +574,19 @@ export const useFirstLegOrdersStore = defineStore('client-first-leg-orders', ()
|
||||
if (submittingIds.has(id)) throw new Error('订单正在提交,请稍候')
|
||||
submittingIds.add(id)
|
||||
try {
|
||||
let pending = pendingSubmissions.get(id)
|
||||
// Always observe the raw detail; a retry must retain the original command.
|
||||
const { order } = await getMerchantFirstLegOrder(id)
|
||||
if (!pending) {
|
||||
if (order.status !== 'DRAFT') throw new Error('当前订单不是草稿,请刷新订单查看最新状态')
|
||||
if (!Number.isSafeInteger(order.version) || order.version < 0) throw new Error('订单版本缺失,请重新加载详情')
|
||||
pending = { key: createIdempotencyKey(`first-leg-submit-${id}`), payload: { expectedVersion: order.version } }
|
||||
pendingSubmissions.set(id, pending)
|
||||
}
|
||||
await submitMerchantFirstLegOrder(id, pending.payload, pending.key)
|
||||
const submitted = await loadOrderAggregate(id)
|
||||
pendingSubmissions.delete(id)
|
||||
submissionForms.delete(id)
|
||||
return submitted
|
||||
if (order.status !== 'DRAFT') throw new Error('当前订单不是草稿,请刷新订单查看最新状态')
|
||||
if (!Number.isSafeInteger(order.version) || order.version < 0) throw new Error('订单版本缺失,请重新加载详情')
|
||||
await submitMerchantFirstLegOrder(id, { expectedVersion: order.version }, createIdempotencyKey(`first-leg-submit-${id}`))
|
||||
return await loadOrderAggregate(id)
|
||||
} finally {
|
||||
submittingIds.delete(id)
|
||||
}
|
||||
}
|
||||
|
||||
function hasPendingSubmission(id?: string) { return !!id && (pendingSubmissions.has(id) || submissionForms.has(id)) }
|
||||
|
||||
function isSubmissionRetry(id: string | undefined, draft: FirstLegOrderDraft) {
|
||||
return !!id && hasPendingSubmission(id) && submissionForms.get(id)?.snapshot === JSON.stringify(draft)
|
||||
}
|
||||
|
||||
async function beginNewSubmissionEdit(id: string) {
|
||||
if (submittingIds.has(id)) throw new Error('订单正在提交,请稍候')
|
||||
const detail = await getMerchantFirstLegOrder(id)
|
||||
if (detail.order.status !== 'DRAFT') throw new Error('订单已不在草稿状态,不能重新编辑,请刷新订单查看最新状态')
|
||||
if (!Number.isSafeInteger(detail.order.version) || detail.order.version < 0) throw new Error('订单版本缺失,请重新加载详情')
|
||||
const order = mapOrder(detail.order, warehouses.value, detail)
|
||||
const session = beginDraftEdit(order)
|
||||
pendingSubmissions.delete(id)
|
||||
submissionForms.delete(id)
|
||||
upsertOrder(order)
|
||||
return session
|
||||
}
|
||||
|
||||
async function saveDraftForSubmission(draft: FirstLegOrderDraft, customerName: string, id?: string, editSession?: DraftEditSession) {
|
||||
if (id && isSubmissionRetry(id, draft)) return submissionForms.get(id)!.order
|
||||
const snapshot = JSON.stringify(draft)
|
||||
const order = await saveDraft(JSON.parse(snapshot), customerName, id, editSession)
|
||||
submissionForms.set(order.id, { snapshot, order })
|
||||
return order
|
||||
}
|
||||
|
||||
async function loadDraftDetail(id: string) {
|
||||
return loadOrderAggregate(id)
|
||||
}
|
||||
|
||||
return { orders, orderDetails, total, queueCounts, orderProgress, queryChannelNames, warehouses, loading, loadedFromApi, loadError, warehouseLoadError, getById, load, loadDetail, loadDraftDetail, loadWarehouseDetail, loadWarehouseType, beginDraftEdit, saveDraft, prepareCancellation, cancelOrder, saveDraftBatch, submitSaved, hasPendingSubmission, isSubmissionRetry, beginNewSubmissionEdit, saveDraftForSubmission }
|
||||
return { orders, orderDetails, total, queueCounts, orderProgress, queryChannelNames, warehouses, loading, loadedFromApi, loadError, warehouseLoadError, getById, load, loadDetail, loadDraftDetail, loadWarehouseDetail, loadWarehouseType, beginDraftEdit, saveDraft, prepareCancellation, cancelOrder, saveDraftBatch, submitSaved }
|
||||
})
|
||||
|
||||
@@ -642,12 +642,41 @@ test('opens billing-weight confirmation independently from order details', () =>
|
||||
assert.match(source, /unavailable-message="未推送费用"/)
|
||||
})
|
||||
|
||||
test('shows billing-weight confirmation only when the backend marks it pending', () => {
|
||||
assert.match(source, /if \(canConfirmInboundFee\.value && order\.businessSummary\.customerFeeConfirmationRequired\) \{\s*actions\.push\(\{ key: 'fee'/)
|
||||
test('only offers published-fee confirmation for pending orders with confirmation permission', () => {
|
||||
const actions = source.slice(source.indexOf('function getOrderRowActions'), source.indexOf('function getOrderRowActions') + 1800)
|
||||
assert.match(actions, /actions\.push\(\{ key: 'fee', label: '确认计费重', run: \(\) => openFeeConfirmation\(order\) \}\)/)
|
||||
assert.match(actions, /if \(canConfirmInboundFee\.value && order\.businessSummary\.customerFeeConfirmationRequired\) \{\s*actions\.push\(\{ key: 'fee'/)
|
||||
assert.doesNotMatch(actions, /label: '确认费用'|key: 'weight'/)
|
||||
assert.doesNotMatch(source, /ChargeableWeightDialog|weightConfirmationOrderId/)
|
||||
assert.match(source, /:row-actions="getOrderRowActions"/)
|
||||
assert.match(orderStoreSource, /customerFeeConfirmationRequired: summary\?\.customerFeeConfirmationRequired \?\? false/)
|
||||
})
|
||||
|
||||
test('hides confirmation for confirmed, unpushed and unauthorized orders and refreshes after confirmation', () => {
|
||||
const start = source.indexOf('function getOrderRowActions')
|
||||
const end = source.indexOf('\nasync function copyOrder', start)
|
||||
const body = source.slice(start, end)
|
||||
.replace('function getOrderRowActions(row: object): TableAction[]', 'function getOrderRowActions(row)')
|
||||
.replace('const order = row as FirstLegOrder', 'const order = row')
|
||||
.replace('const actions: TableAction[]', 'const actions')
|
||||
const actionsFor = new Function('canConfirmInboundFee', 'canCreateOrder', 'canEditOrder',
|
||||
'canOfferCancellation', 'eligibleCustomsDetail', 'openFeeConfirmation',
|
||||
`${body}; return getOrderRowActions`)
|
||||
for (const [permitted, pending] of [[true, true], [true, false], [false, true], [false, false]]) {
|
||||
const opened = []
|
||||
const order = { id: 'order-1', businessSummary: { customerFeeConfirmationRequired: pending } }
|
||||
const getActions = actionsFor({ value: permitted }, { value: false }, { value: false },
|
||||
() => false, () => false, row => opened.push(row.id))
|
||||
const confirm = getActions(order).filter(action => action.key === 'fee')
|
||||
assert.equal(confirm.length, permitted && pending ? 1 : 0)
|
||||
if (confirm.length) {
|
||||
confirm[0].run()
|
||||
assert.deepEqual(opened, ['order-1'])
|
||||
}
|
||||
}
|
||||
assert.match(source, /function handleInboundFeeConfirmed\(\) \{\s*if \(!isCreatePage\.value && !isDetailPage\.value\) void loadOrderPage\(\)/)
|
||||
})
|
||||
|
||||
test('submits only selected draft orders in one batch action', () => {
|
||||
assert.match(source, /selectedDraftOrders = computed\(\(\) => selectedOrders\.value\.filter\(\(order\) => order\.status === 'DRAFT'\)\)/)
|
||||
assert.match(source, /Promise\.allSettled\(ids\.map\(id => store\.submitSaved/)
|
||||
|
||||
@@ -9,7 +9,6 @@ import DataTable, { type DataTableColumn } from '@/components/common/DataTable.v
|
||||
import type { TableAction } from '@/components/common/tableActions'
|
||||
import { ApiError } from '@/api/http'
|
||||
import FirstLegOrderEditorShell from '@/modules/first-leg/components/FirstLegOrderEditorShell.vue'
|
||||
import ChargeableWeightDialog from '@/modules/first-leg/components/ChargeableWeightDialog.vue'
|
||||
import InboundBillingPanel from '@/modules/first-leg/components/InboundBillingPanel.vue'
|
||||
import InboundCodeAssociationDialog from '@/modules/first-leg/components/InboundCodeAssociationDialog.vue'
|
||||
import OrderProgressPanel from '@/modules/first-leg/components/OrderProgressPanel.vue'
|
||||
@@ -86,7 +85,6 @@ const canCreateOrder = computed(() => auth.hasPermission('order:first-leg:create
|
||||
const canEditOrder = computed(() => auth.hasPermission('order:first-leg:edit'))
|
||||
const canCancelOrder = computed(() => auth.hasPermission('order:first-leg:cancel'))
|
||||
const cancellingOrderId = ref('')
|
||||
const pendingCancellation = shallowRef<{ id: string; expectedVersion: number; reason: string; businessNo: string; statusLabel: string }>()
|
||||
|
||||
function canOfferCancellation(order: FirstLegOrder) {
|
||||
return canCancelOrder.value && ['DRAFT', 'PENDING_REVIEW', 'WAIT_MEASURE'].includes(order.status)
|
||||
@@ -96,40 +94,20 @@ async function cancelOrder(order: FirstLegOrder) {
|
||||
if (!canOfferCancellation(order) || cancellingOrderId.value) return
|
||||
cancellingOrderId.value = order.id
|
||||
try {
|
||||
let command = pendingCancellation.value
|
||||
if (command && command.id !== order.id) {
|
||||
ElMessage.warning(`请先处理订单 ${command.businessNo} 未确认的取消结果`)
|
||||
return
|
||||
}
|
||||
if (!command) {
|
||||
const target = await store.prepareCancellation(order.id)
|
||||
const { value } = await ElMessageBox.prompt(`订单:${target.businessNo};当前状态:${target.statusLabel}。请填写取消原因。`, '取消订单', {
|
||||
const target = await store.prepareCancellation(order.id)
|
||||
const { value } = await ElMessageBox.prompt(
|
||||
`订单:${target.businessNo};当前状态:${target.statusLabel}。请填写取消原因。`, '取消订单', {
|
||||
type: 'warning', inputType: 'textarea', confirmButtonText: '确认取消订单', cancelButtonText: '返回',
|
||||
inputValidator: value => Boolean(value?.trim()) && value.trim().length <= 500 || '请填写 1–500 字取消原因',
|
||||
})
|
||||
command = { ...target, reason: value.trim() }
|
||||
pendingCancellation.value = command
|
||||
} else {
|
||||
await ElMessageBox.confirm(`订单:${command.businessNo};原状态:${command.statusLabel};原因:${command.reason}。将查询当前状态并重试原取消请求。`, '重试取消订单', {
|
||||
type: 'warning', confirmButtonText: '重试原请求', cancelButtonText: '返回',
|
||||
})
|
||||
}
|
||||
await store.cancelOrder(command.id, command.expectedVersion, command.reason)
|
||||
pendingCancellation.value = undefined
|
||||
ElMessage.success('订单已取消')
|
||||
await loadOrderPage()
|
||||
await store.cancelOrder(target.id, target.expectedVersion, value.trim())
|
||||
ElMessage.success('订单已取消'); await loadOrderPage()
|
||||
if (isDetailPage.value) await router.push({ name: 'first-leg-orders' })
|
||||
} catch (error) {
|
||||
if (error === 'cancel' || error === 'close') return
|
||||
if (error instanceof ApiError && (error.code === 'A0409' || error.status === 409)) {
|
||||
pendingCancellation.value = undefined
|
||||
ElMessage.error(`${error.message}。请刷新订单后重新确认取消。`)
|
||||
} else {
|
||||
ElMessage.error(error instanceof Error ? error.message : '取消失败,请重试原请求')
|
||||
}
|
||||
} finally {
|
||||
cancellingOrderId.value = ''
|
||||
}
|
||||
ElMessage.error(error instanceof Error ? error.message : '取消失败,请重新操作')
|
||||
void loadOrderPage()
|
||||
} finally { cancellingOrderId.value = '' }
|
||||
}
|
||||
const canSubmitOrder = computed(() => auth.hasPermission('order:first-leg:submit'))
|
||||
const canConfirmInboundFee = computed(() => auth.hasPermission('order:first-leg:edit'))
|
||||
@@ -243,7 +221,6 @@ const tablePageSize = ref(10)
|
||||
const downloadingMarks = ref(false)
|
||||
const exportingOrders = ref(false)
|
||||
const batchSubmitting = ref(false)
|
||||
const pendingBatchSubmissionIds = ref<string[]>([])
|
||||
const selectedOrders = ref<FirstLegOrder[]>([])
|
||||
const selectedOrderCount = computed(() => selectedOrders.value.length)
|
||||
const selectedDraftOrders = computed(() => selectedOrders.value.filter((order) => order.status === 'DRAFT'))
|
||||
@@ -268,7 +245,6 @@ const inboundBillingUnavailableMessage = ref('还未测量推送')
|
||||
const inboundBillingError = ref('')
|
||||
const inboundBillingOrderId = ref('')
|
||||
const feeConfirmationOpen = ref(false)
|
||||
const weightConfirmationOrderId = ref('')
|
||||
const customsByOrder = reactive<Record<string, MerchantCustomsContainer | null | undefined>>({})
|
||||
const customsEligibilityPending = new Set<string>()
|
||||
const customsDialogOpen = ref(false)
|
||||
@@ -1363,17 +1339,14 @@ function getOrderRowActions(row: object): TableAction[] {
|
||||
if (canCreateOrder.value) {
|
||||
actions.push({ key: 'copy', label: '复制下单', loading: copyingOrderId.value === order.id, run: () => copyOrder(order) })
|
||||
}
|
||||
if (canConfirmInboundFee.value && !['DRAFT', 'CANCELLED', 'REJECTED', 'SUBMITTED'].includes(order.status)) {
|
||||
actions.push({ key: 'weight', label: '确认计费重', run: () => { weightConfirmationOrderId.value = order.id } })
|
||||
}
|
||||
if (canConfirmInboundFee.value && order.businessSummary.customerFeeConfirmationRequired) {
|
||||
actions.push({ key: 'fee', label: '确认费用', run: () => openFeeConfirmation(order) })
|
||||
actions.push({ key: 'fee', label: '确认计费重', run: () => openFeeConfirmation(order) })
|
||||
}
|
||||
if (canEditOrder.value && canClientEditFirstLegOrder(order.status)) {
|
||||
actions.push({ key: 'edit', label: '编辑', loading: openingEditor.value, run: () => openEdit(order) })
|
||||
}
|
||||
if (canOfferCancellation(order)) {
|
||||
actions.push({ key: 'cancel', label: pendingCancellation.value?.id === order.id ? '重试取消' : '取消订单', loading: cancellingOrderId.value === order.id, disabled: Boolean(cancellingOrderId.value), run: () => cancelOrder(order) })
|
||||
actions.push({ key: 'cancel', label: '取消订单', loading: cancellingOrderId.value === order.id, disabled: Boolean(cancellingOrderId.value), run: () => cancelOrder(order) })
|
||||
}
|
||||
if (eligibleCustomsDetail(order)) {
|
||||
actions.push({ key: 'customs', label: '报关资料', run: () => openCustomsDocuments(order) })
|
||||
@@ -1756,14 +1729,14 @@ function handleOrderSelectionChange(rows: FirstLegOrder[]) {
|
||||
}
|
||||
|
||||
async function submitSelectedDraftOrders() {
|
||||
const ids = [...new Set([...pendingBatchSubmissionIds.value, ...selectedDraftOrders.value.map(order => order.id)])]
|
||||
const ids = [...new Set(selectedDraftOrders.value.map(order => order.id))]
|
||||
if (batchSubmitting.value || !ids.length) return
|
||||
if (companySubmissionBlocked.value) {
|
||||
ElMessage.warning('企业资料审核通过后才能提交订单')
|
||||
return
|
||||
}
|
||||
try {
|
||||
await ElMessageBox.confirm(`确认提交 ${ids.length} 条草稿订单吗?${pendingBatchSubmissionIds.value.length ? '上次结果未确认的订单将使用原提交命令重试。' : ''}`, '批量提交订单', {
|
||||
await ElMessageBox.confirm(`确认提交 ${ids.length} 条草稿订单吗?`, '批量提交订单', {
|
||||
type: 'warning',
|
||||
confirmButtonText: '确认提交',
|
||||
cancelButtonText: '取消',
|
||||
@@ -1776,7 +1749,6 @@ async function submitSelectedDraftOrders() {
|
||||
batchSubmitting.value = true
|
||||
try {
|
||||
const results = await Promise.allSettled(ids.map(id => store.submitSaved(id, companyAuditLoaded.value ? tenantStore.company.auditStatus : undefined)))
|
||||
pendingBatchSubmissionIds.value = ids.filter((id, index) => results[index]?.status === 'rejected' && store.hasPendingSubmission(id))
|
||||
const successCount = results.filter((result) => result.status === 'fulfilled').length
|
||||
const failures = results.filter((result): result is PromiseRejectedResult => result.status === 'rejected')
|
||||
await searchOrders(appliedFilters.value)
|
||||
@@ -2029,7 +2001,6 @@ async function saveDraft() {
|
||||
if (!await validateEditorForm()) return
|
||||
saving.value = true
|
||||
try {
|
||||
if (!await confirmSubmissionEdit()) return
|
||||
const order = await store.saveDraft(cloneDraft(form), tenantStore.company.companyName, editingId.value, editingSession.value)
|
||||
editingId.value = order.id
|
||||
editingSession.value = store.beginDraftEdit(order)
|
||||
@@ -2044,20 +2015,6 @@ async function saveDraft() {
|
||||
}
|
||||
}
|
||||
|
||||
async function confirmSubmissionEdit() {
|
||||
if (!editingId.value || !store.hasPendingSubmission(editingId.value)) return true
|
||||
try {
|
||||
await ElMessageBox.confirm('上次提交结果尚未确认。确认重新读取订单并按当前表单重新编辑吗?只有服务端仍为草稿时才能开始新的提交决定。', '重新编辑订单', {
|
||||
type: 'warning', center: true, confirmButtonText: '确认重新编辑', cancelButtonText: '返回',
|
||||
})
|
||||
} catch (error) {
|
||||
if (error === 'cancel' || error === 'close') return false
|
||||
throw error
|
||||
}
|
||||
editingSession.value = await store.beginNewSubmissionEdit(editingId.value)
|
||||
return true
|
||||
}
|
||||
|
||||
async function submitOrder() {
|
||||
if (saving.value) return
|
||||
if (companySubmissionBlocked.value) {
|
||||
@@ -2076,14 +2033,12 @@ async function submitOrder() {
|
||||
}
|
||||
return
|
||||
}
|
||||
const retry = store.isSubmissionRetry(editingId.value, cloneDraft(form))
|
||||
if (!retry && !await validateEditorForm()) return
|
||||
if (!await validateEditorForm()) return
|
||||
|
||||
try {
|
||||
saving.value = true
|
||||
if (!retry && !await confirmSubmissionEdit()) return
|
||||
const knownCompanyAuditStatus = companyAuditLoaded.value ? tenantStore.company.auditStatus : undefined
|
||||
const savedOrder = await store.saveDraftForSubmission(cloneDraft(form), tenantStore.company.companyName, editingId.value, editingSession.value)
|
||||
const savedOrder = await store.saveDraft(cloneDraft(form), tenantStore.company.companyName, editingId.value, editingSession.value)
|
||||
editingId.value = savedOrder.id
|
||||
editingSession.value = store.beginDraftEdit(savedOrder)
|
||||
await store.submitSaved(savedOrder.id, knownCompanyAuditStatus)
|
||||
@@ -2120,16 +2075,16 @@ async function searchOrders(model: QueryModel) {
|
||||
<QueryToolbar v-model="filters" class="first-leg-query-toolbar" layout="grid" :fields="queryFields" ariaLabel="订单查询" @search="searchOrders" />
|
||||
|
||||
<div class="client-card order-table-card">
|
||||
<nav class="order-queue-tabs" aria-label="订单事项分类">
|
||||
<button v-for="queue in ORDER_QUEUES" :key="queue.key" type="button"
|
||||
:class="{ active: activeOrderQueue === queue.key }" :aria-pressed="activeOrderQueue === queue.key"
|
||||
@click="selectOrderQueue(queue.key)">
|
||||
{{ queue.label }}<span v-if="queue.key !== 'all' && orderQueueCounts[queue.key]"
|
||||
:class="queue.todo ? 'queue-count' : 'queue-stage-count'">{{ queue.todo ? orderQueueCounts[queue.key] : `(${orderQueueCounts[queue.key]})` }}</span>
|
||||
</button>
|
||||
</nav>
|
||||
<DataTable :page="tablePage" :page-size="tablePageSize" @update:page="changeOrderPage" @update:page-size="changeOrderPageSize" :data="pagedOrders" :columns="visibleOrderColumns" :key="orderTableVersion" :loading="store.loading" :total="store.total" :page-sizes="[10, 20, 50]" row-key="id" empty-text="暂无订单" class="prototype-order-table" :row-actions="getOrderRowActions" @selection-change="handleOrderSelectionChange">
|
||||
<template #toolbar>
|
||||
<nav class="order-queue-tabs" aria-label="订单事项分类">
|
||||
<button v-for="queue in ORDER_QUEUES" :key="queue.key" type="button"
|
||||
:class="{ active: activeOrderQueue === queue.key }" :aria-pressed="activeOrderQueue === queue.key"
|
||||
@click="selectOrderQueue(queue.key)">
|
||||
{{ queue.label }}<span v-if="queue.key !== 'all' && orderQueueCounts[queue.key]"
|
||||
:class="queue.todo ? 'queue-count' : 'queue-stage-count'">{{ queue.todo ? orderQueueCounts[queue.key] : `(${orderQueueCounts[queue.key]})` }}</span>
|
||||
</button>
|
||||
</nav>
|
||||
<span v-if="selectedOrderCount">已选 {{ selectedOrderCount }} 条</span>
|
||||
</template>
|
||||
<template #toolbar-actions>
|
||||
@@ -2161,7 +2116,7 @@ async function searchOrders(model: QueryModel) {
|
||||
</el-popover>
|
||||
<el-button :loading="downloadingMarks" :disabled="selectedOrderCount === 0" @click="downloadShippingMarks"><Download :size="16" />下载唛头</el-button>
|
||||
<el-button :loading="exportingOrders" :disabled="selectedOrderCount === 0" @click="exportOrderInformation"><Download :size="16" />导出订单信息</el-button>
|
||||
<el-button v-if="canSubmitOrder" :loading="batchSubmitting" :disabled="(selectedDraftOrders.length === 0 && pendingBatchSubmissionIds.length === 0) || companySubmissionBlocked" @click="submitSelectedDraftOrders"><Send :size="17" />{{ pendingBatchSubmissionIds.length ? '重试批量提交' : '批量提交草稿' }}</el-button>
|
||||
<el-button v-if="canSubmitOrder" :loading="batchSubmitting" :disabled="selectedDraftOrders.length === 0 || companySubmissionBlocked" @click="submitSelectedDraftOrders"><Send :size="17" />批量提交草稿</el-button>
|
||||
<el-button v-if="auth.hasPermission('order:first-leg:create')" @click="openBatchImport"><Upload :size="17" />批量导入订单</el-button>
|
||||
<el-button v-if="props.showCreateAction && auth.hasPermission('order:first-leg:create')" type="primary" :loading="pageDataLoading" :disabled="pageDataLoading || availableWarehouses.length === 0" @click="openCreate"><FilePlus2 :size="17" />创建订单</el-button>
|
||||
|
||||
@@ -2428,7 +2383,7 @@ async function searchOrders(model: QueryModel) {
|
||||
<el-button link type="primary" class="detail-back-action" @click="router.push({ name: 'first-leg-orders' })">← 返回列表</el-button>
|
||||
<div><h2>{{ detailOrder.businessSummary.inboundCode || (detailOrder.status === 'CANCELLED' ? (detailOrder.orderNo || '—') : detailOrder.status === 'DRAFT' ? '入仓码提交后生成' : '入仓码待生成') }}</h2><p v-if="detailOrder.status === 'CANCELLED'">订单已取消。</p><p v-else>{{ getFirstLegTransportModeLabel(detailOrder.transportMode) }} · {{ detailOrder.origin || '起运地待更新' }} → {{ detailOrder.destination || '目的地待更新' }}</p></div>
|
||||
</div>
|
||||
<div class="detail-heading-actions"><el-tag :type="getFirstLegStatusTone(detailOrder.status)" effect="light">{{ getFirstLegStatusLabel(detailOrder.status) }}</el-tag><el-button v-if="canEditOrder && canClientEditFirstLegOrder(detailOrder.status)" type="primary" plain :loading="openingEditor" @click="openEdit(detailOrder)"><Pencil :size="16" />编辑草稿</el-button><el-button v-if="canOfferCancellation(detailOrder)" type="danger" plain :loading="cancellingOrderId === detailOrder.id" :disabled="!!cancellingOrderId" @click="cancelOrder(detailOrder)">{{ pendingCancellation?.id === detailOrder.id ? '重试取消' : '取消订单' }}</el-button></div>
|
||||
<div class="detail-heading-actions"><el-tag :type="getFirstLegStatusTone(detailOrder.status)" effect="light">{{ getFirstLegStatusLabel(detailOrder.status) }}</el-tag><el-button v-if="canEditOrder && canClientEditFirstLegOrder(detailOrder.status)" type="primary" plain :loading="openingEditor" @click="openEdit(detailOrder)"><Pencil :size="16" />编辑草稿</el-button><el-button v-if="canOfferCancellation(detailOrder)" type="danger" plain :loading="cancellingOrderId === detailOrder.id" :disabled="!!cancellingOrderId" @click="cancelOrder(detailOrder)">取消订单</el-button></div>
|
||||
</div>
|
||||
<section class="detail-section">
|
||||
<h3>订单与运输</h3>
|
||||
@@ -2560,7 +2515,6 @@ async function searchOrders(model: QueryModel) {
|
||||
@confirmed="handleInboundFeeConfirmed"
|
||||
@closed="feeConfirmationOpen = false"
|
||||
/>
|
||||
<ChargeableWeightDialog v-if="weightConfirmationOrderId" :order-id="weightConfirmationOrderId" :can-confirm="canConfirmInboundFee" @close="weightConfirmationOrderId = ''" @confirmed="handleInboundFeeConfirmed" />
|
||||
<CustomsDocumentsDialog
|
||||
v-model="customsDialogOpen"
|
||||
:order-id="customsDialogOrderId"
|
||||
@@ -2592,10 +2546,7 @@ async function searchOrders(model: QueryModel) {
|
||||
.supporting-data-error span { overflow-wrap: anywhere; color: var(--muted); font-size: 11px; line-height: 1.55; }
|
||||
.order-row-actions, .editor-actions { display: flex; justify-content: flex-end; gap: 8px; }
|
||||
.order-table-card { padding: 0; overflow: hidden; border: 1px solid var(--client-border); border-radius: var(--client-radius); box-shadow: none; }
|
||||
.prototype-order-table :deep(.data-table__toolbar) { flex-wrap: nowrap; }
|
||||
.prototype-order-table :deep(.data-table__toolbar-heading) { min-width: 0; flex: 1; flex-wrap: nowrap; }
|
||||
.prototype-order-table :deep(.data-table__toolbar-actions) { flex-shrink: 0; }
|
||||
.order-queue-tabs { display: flex; min-width: 0; align-items: center; gap: 4px; overflow-x: auto; padding: 7px 0 10px; scrollbar-width: thin; }
|
||||
.order-queue-tabs { display: flex; min-width: 0; align-items: center; gap: 4px; overflow-x: auto; padding: 14px 16px 10px; border-bottom: 1px solid var(--client-border); scrollbar-width: thin; }
|
||||
.order-queue-tabs button { flex-shrink: 0; white-space: nowrap; }
|
||||
.queue-stage-count { margin-left: 3px; }
|
||||
.order-queue-tabs button { position: relative; min-height: 34px; padding: 0 12px; border: 1px solid transparent; border-radius: 7px; background: transparent; color: #667085; cursor: pointer; font: inherit; font-weight: 600; }
|
||||
|
||||
@@ -6,8 +6,8 @@ const data = ref<RelabelQuantityTotals | null>(null)
|
||||
const error = ref('')
|
||||
let generation = 0
|
||||
function dimension(known: number, unknown: number, unit: string) {
|
||||
if (unknown > 0 && known === 0) return `未提供(${unknown} 票)`
|
||||
return `已知 ${known} ${unit}${unknown > 0 ? `(${unknown} 票未提供)` : ''}`
|
||||
if (unknown > 0 && known === 0) return `—(${unknown} 票)`
|
||||
return `已知 ${known} ${unit}${unknown > 0 ? `(${unknown} 票 —)` : ''}`
|
||||
}
|
||||
watch(() => [props.query, props.relabelNo], async () => {
|
||||
const current = ++generation
|
||||
|
||||
@@ -29,7 +29,7 @@ watch(() => props.transferNo, load, { immediate: true }); onBeforeUnmount(() =>
|
||||
<div><dt>取货进度</dt><dd>{{ labels[progress.status] || progress.status }}</dd></div><div><dt>车次号</dt><dd>{{ progress.tripNo || '待安排' }}</dd></div>
|
||||
<div><dt>车牌</dt><dd>{{ progress.vehiclePlate || '待分配' }}</dd></div><div><dt>司机</dt><dd>{{ progress.driverName || '待分配' }}</dd></div>
|
||||
<div><dt>司机电话</dt><dd>{{ progress.driverPhone || '—' }}</dd></div><div><dt>计划取货发车</dt><dd>{{ time(progress.plannedDepartureAt) }}</dd></div>
|
||||
<div><dt>实提箱数</dt><dd>{{ progress.actualPackages ?? '待取货' }}</dd></div><div><dt>取货时间</dt><dd>{{ time(progress.pickedAt) }}</dd></div>
|
||||
<div><dt>实际取货数量(箱)</dt><dd>{{ progress.actualPackages ?? '待取货' }}</dd></div><div><dt>取货时间</dt><dd>{{ time(progress.pickedAt) }}</dd></div>
|
||||
<div><dt>送仓时间</dt><dd>{{ time(progress.arrivedAt) }}</dd></div><div v-if="progress.remark"><dt>取货备注</dt><dd>{{ progress.remark }}</dd></div>
|
||||
</dl>
|
||||
<div v-if="progress?.evidence.length" class="pickup-files"><span>取货凭证</span><el-button v-for="file in progress.evidence" :key="file.fileId" link type="primary" @click="download(file)">{{ file.fileName }}</el-button></div>
|
||||
|
||||
File diff suppressed because one or more lines are too long
Reference in New Issue
Block a user