This commit is contained in:
2026-08-19 09:14:38 +08:00
parent eedaa2f080
commit 372ec3dc37
10 changed files with 217 additions and 62 deletions
@@ -73,7 +73,7 @@ test('uses the full editor dialog width for cargo details and cost estimates', (
assert.match(source, /:class="\{ 'is-dialog-order-form': !isCreatePage \}"/)
assert.match(source, /\.order-form\.is-dialog-order-form \{ width: 100%; max-width: none; \}/)
assert.match(source, /\.is-dialog-order-form > \.cargo-section, \.is-dialog-order-form > \.cost-estimate-section \{ width: 100%; max-width: none; \}/)
assert.match(source, /\.cost-estimate-cards \{ display: grid; grid-template-columns: repeat\(3, minmax\(0, 1fr\)\);/)
assert.match(source, /\.price-estimate__result \{ display: grid; grid-template-columns:/)
assert.match(source, /\.cargo-table-wrap \{ width: 100%;/)
})
@@ -361,6 +361,11 @@ test('estimates by warehouse, destination, tax mode, weight and volume without b
assert.match(source, /您仍可正常保存订单草稿/)
assert.match(source, /v-for="mode in availablePricingTaxModes"/)
assert.match(source, /pricingTaxModeLabel\(mode\)/)
assert.match(source, /priceEstimate\.chargeableQuantity/)
assert.match(source, /priceEstimate\.unitPrice/)
assert.match(source, /priceEstimate\.estimatedAmount/)
assert.match(source, /priceEstimateDisclaimer/)
assert.doesNotMatch(source, /3,310|2,990|2,500|静态预估展示/)
assert.doesNotMatch(source, /当前价格表不提供不包税报价|历史草稿的不包税设置/)
const saveSource = source.slice(source.indexOf('async function saveDraft()'), source.indexOf('async function submitOrder()'))
assert.doesNotMatch(saveSource, /loadPriceEstimate|priceEstimateError|estimateMerchantFirstLegPrice/)
@@ -485,6 +490,8 @@ test('copies reactive order drafts into plain request data', () => {
test('uses the global inbound-code policy to require old-system codes during parallel running', () => {
assert.match(source, /getMerchantInboundCodePolicy\(\)/)
assert.match(source, /async function validateEditorForm\(\)[\s\S]*?const policy = await getMerchantInboundCodePolicy\(\)/)
assert.match(source, /if \(policy\.mode === 'AUTO' && !editingId\.value\) form\.inboundCode = ''/)
assert.match(source, /const manualInboundCodeRequired = computed/)
assert.match(source, /v-if="manualInboundCodeRequired" label="旧系统入仓码"/)
assert.match(source, /当前全系统处于旧系统并跑模式/)
@@ -736,6 +736,25 @@ function pricingTaxModeLabel(mode: 'TAX_INCLUDED' | 'TAX_EXCLUDED') {
return mode === 'TAX_INCLUDED' ? '包税' : '不包税'
}
function formatEstimateMoney(value: number, currency: string) {
try {
return new Intl.NumberFormat('zh-CN', {
style: 'currency',
currency,
minimumFractionDigits: 2,
maximumFractionDigits: 2,
}).format(value)
} catch {
return `${currency} ${value.toFixed(2)}`
}
}
function formatEstimateQuantity(value: number, unit: string) {
return `${value.toLocaleString('zh-CN', { maximumFractionDigits: 4 })} ${unit}`
}
const priceEstimateDisclaimer = computed(() => priceEstimate.value?.disclaimer || '仅供参考,最终以实际结算为准')
function resetPriceEstimate() {
estimateRequestSequence += 1
priceEstimate.value = null
@@ -815,6 +834,10 @@ async function loadPriceEstimate() {
}
function schedulePriceEstimate() {
estimateRequestSequence += 1
priceEstimate.value = null
priceEstimateError.value = ''
priceEstimateLoading.value = false
if (estimateTimer) clearTimeout(estimateTimer)
estimateTimer = setTimeout(() => void loadPriceEstimate(), 300)
}
@@ -1389,6 +1412,17 @@ async function importCargoTemplate(event: Event) {
}
async function validateEditorForm() {
try {
const policy = await getMerchantInboundCodePolicy()
inboundCodePolicy.value = policy
if (policy.mode === 'AUTO' && !editingId.value) form.inboundCode = ''
await nextTick()
} catch (error) {
inboundCodePolicy.value = null
ElMessage.warning(`入仓码配置加载失败:${errorMessage(error)}`)
return false
}
let fieldsValid = false
try {
fieldsValid = await orderFormRef.value?.validate() ?? false
@@ -1400,10 +1434,6 @@ async function validateEditorForm() {
return false
}
if (!inboundCodePolicy.value) {
ElMessage.warning('入仓码配置尚未加载,请稍后重试')
return false
}
if (manualInboundCodeRequired.value && !form.inboundCode?.trim()) {
ElMessage.warning('当前为旧系统并跑模式,请填写旧系统入仓码')
return false
@@ -1730,28 +1760,28 @@ async function searchOrders(model: QueryModel) {
</section>
<section class="order-form-section prototype-section cost-estimate-section" aria-label="费用预估">
<div class="order-section-heading"><div><h3>费用预估</h3></div></div>
<div class="cost-estimate-cards">
<article class="cost-estimate-card">
<span class="cost-estimate-badge is-fastest">最快</span>
<strong class="cost-estimate-days">10天</strong>
<div class="cost-estimate-price"><small>¥</small><strong>3,310</strong></div>
<p>优先配送,时效保障</p>
</article>
<article class="cost-estimate-card is-recommended">
<span class="cost-estimate-badge is-recommend">推荐</span>
<strong class="cost-estimate-days">13天</strong>
<div class="cost-estimate-price"><small>¥</small><strong>2,990</strong></div>
<p>性价比之选</p>
</article>
<article class="cost-estimate-card">
<span class="cost-estimate-badge is-economy">经济</span>
<strong class="cost-estimate-days">16天</strong>
<div class="cost-estimate-price"><small>¥</small><strong>2,500</strong></div>
<p>经济实惠</p>
</article>
<div class="order-section-heading"><div><h3>参考运费</h3><p>根据当前价格表、渠道、目的仓以及货物重量和体积实时试算。</p></div></div>
<div class="price-estimate" :class="{ 'is-loading': priceEstimateLoading }" aria-live="polite">
<div v-if="priceEstimateLoading" class="price-estimate__state" v-loading="true">正在获取实时参考报价</div>
<div v-else-if="priceEstimateError" class="price-estimate__state is-error" role="alert">
<AlertTriangle :size="20" />
<div><strong>参考报价暂时不可用</strong><span>{{ priceEstimateError }},您仍可正常保存订单草稿。</span></div>
<el-button @click="loadPriceEstimate">重新试算</el-button>
</div>
<div v-else-if="priceEstimate" class="price-estimate__result">
<div class="price-estimate__channel">
<span>当前渠道</span>
<strong>{{ selectedPricingChannel?.channelName || priceEstimate.channelCode }}</strong>
<small>{{ pricingTaxModeLabel(priceEstimate.pricingTaxMode) }}<template v-if="selectedPricingChannel?.referenceTransit"> · 参考时效 {{ selectedPricingChannel.referenceTransit }}</template></small>
</div>
<div><span>计费量</span><strong>{{ formatEstimateQuantity(priceEstimate.chargeableQuantity, priceEstimate.chargeUnit) }}</strong></div>
<div><span>基础单价</span><strong>{{ formatEstimateMoney(priceEstimate.unitPrice, priceEstimate.currency) }} / {{ priceEstimate.chargeUnit }}</strong></div>
<div class="price-estimate__amount"><span>参考运费</span><strong>{{ formatEstimateMoney(priceEstimate.estimatedAmount, priceEstimate.currency) }}</strong></div>
<small>{{ priceEstimateDisclaimer }}</small>
</div>
<div v-else-if="form.destinationType === 'PRIVATE'" class="price-estimate__state">私人仓暂不提供在线参考报价,您仍可正常保存订单草稿。</div>
<div v-else class="price-estimate__state">请先选择国内收货仓、渠道、目的仓,并填写大于 0 的总毛重和总体积。</div>
</div>
<p class="cost-estimate-note">以上费用为静态预估展示,实际费用以最终结算结果为准。</p>
</section>
</el-form>
<template #footer><div class="editor-actions"><el-button :disabled="saving" @click="closeEditor">返回</el-button><el-button v-if="editingId ? canEditOrder : canCreateOrder" :loading="saving" @click="saveDraft">保存草稿</el-button><el-button v-if="auth.hasPermission('order:first-leg:submit')" type="primary" :loading="saving" @click="submitOrder"><Send :size="16" />{{ companySubmissionBlocked ? '提交前需完成资料审核' : '提交订单' }}</el-button></div></template>
@@ -2015,18 +2045,20 @@ async function searchOrders(model: QueryModel) {
.field-guidance--error { color: #b54708; }
.cost-estimate-section { width: 100%; }
.cost-estimate-section .order-section-heading { margin-bottom: 12px; }
.cost-estimate-cards { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; }
.cost-estimate-card { position: relative; display: flex; min-height: 158px; box-sizing: border-box; align-items: center; justify-content: center; flex-direction: column; padding: 24px 18px 18px; border: 1px solid #dde4f2; border-radius: 8px; background: #fff; box-shadow: 0 2px 8px rgba(15, 31, 58, .025); text-align: center; }
.cost-estimate-card.is-recommended { border: 2px solid #637fec; background: #f8f8ff; box-shadow: 0 8px 22px rgba(99, 127, 236, .13); }
.cost-estimate-badge { position: absolute; top: -9px; right: 14px; padding: 3px 11px; border-radius: 12px; color: #fff; font-size: 10px; font-weight: 650; line-height: 1.4; }
.cost-estimate-badge.is-fastest, .cost-estimate-badge.is-recommend { background: #5368c6; }
.cost-estimate-badge.is-economy { background: #71858e; }
.cost-estimate-days { color: #30343b; font-size: 21px; }
.cost-estimate-price { display: flex; align-items: baseline; gap: 5px; margin-top: 13px; color: #637fec; }
.cost-estimate-price small { font-size: 15px; font-weight: 700; }
.cost-estimate-price strong { font-size: 29px; line-height: 1; }
.cost-estimate-card p { margin: 12px 0 0; color: #98a0ad; font-size: 11px; }
.cost-estimate-note { margin: 10px 0 0; color: #98a0ad; font-size: 10px; text-align: right; }
.price-estimate { min-height: 126px; overflow: hidden; border: 1px solid #dde4f2; border-radius: 8px; background: #fff; box-shadow: 0 2px 8px rgba(15, 31, 58, .025); }
.price-estimate__state { display: flex; min-height: 126px; align-items: center; justify-content: center; gap: 10px; padding: 24px; color: #7b8798; font-size: 12px; text-align: center; }
.price-estimate__state.is-error { justify-content: flex-start; background: #fffaf0; color: #b54708; text-align: left; }
.price-estimate__state.is-error > div { display: flex; min-width: 0; flex: 1; flex-direction: column; gap: 4px; }
.price-estimate__state.is-error strong { color: #7a2e0e; font-size: 13px; }
.price-estimate__state.is-error span { overflow-wrap: anywhere; }
.price-estimate__result { display: grid; grid-template-columns: minmax(190px, 1.3fr) repeat(2, minmax(140px, .8fr)) minmax(190px, 1fr); align-items: stretch; }
.price-estimate__result > div { display: flex; min-width: 0; min-height: 96px; justify-content: center; flex-direction: column; gap: 7px; padding: 18px 20px; border-right: 1px solid #edf0f5; }
.price-estimate__result > div > span { color: #8b96a6; font-size: 11px; }
.price-estimate__result > div > strong { overflow-wrap: anywhere; color: #303b50; font-size: 15px; }
.price-estimate__channel small { color: #7b8798; font-size: 10px; line-height: 1.5; }
.price-estimate__result .price-estimate__amount { border-right: 0; background: #f8f8ff; }
.price-estimate__result .price-estimate__amount strong { color: #637fec; font-size: 25px; }
.price-estimate__result > small { grid-column: 1 / -1; padding: 9px 14px; border-top: 1px solid #edf0f5; color: #98a0ad; font-size: 10px; text-align: right; }
.selected-destination { display: flex; width: min(100%, 720px); align-items: flex-start; gap: 9px; margin: -4px 0 18px 140px; padding: 10px 12px; background: #f2f7f6; color: var(--primary); }
.selected-destination svg { flex: 0 0 17px; margin-top: 2px; }
.selected-destination div { display: flex; min-width: 0; flex-direction: column; gap: 2px; }
@@ -2224,8 +2256,11 @@ async function searchOrders(model: QueryModel) {
.compact-transport-grid > :deep(.el-form-item__label) { min-height: auto; justify-content: flex-start; padding: 0 0 8px; line-height: 1.4; }
.cargo-table-toolbar { align-items: stretch; flex-direction: column; }
.cargo-import-actions, .cargo-table-actions { flex-wrap: wrap; }
.cost-estimate-cards { grid-template-columns: 1fr; }
.cost-estimate-card { min-height: 140px; }
.price-estimate__result { grid-template-columns: 1fr; }
.price-estimate__result > div { min-height: auto; border-right: 0; border-bottom: 1px solid #edf0f5; }
.price-estimate__result > small { grid-column: auto; }
.price-estimate__result > small { text-align: left; }
.price-estimate__state.is-error { align-items: flex-start; flex-direction: column; }
.form-span-full { grid-column: auto; }
.editor-actions :deep(.el-button) { min-height: 44px; }
.desktop-order-table { display: none; }
@@ -51,6 +51,9 @@ test('creates one real backend draft per order row and keeps its products togeth
})
test('requires the old inbound code globally only while legacy manual mode is active', () => {
assert.match(source, /async function refreshInboundCodePolicyForWrite\(\)/)
assert.match(source, /if \(!await refreshInboundCodePolicyForWrite\(\)\) return/)
assert.match(source, /if \(policy\.mode === 'AUTO'\)[\s\S]*?row\.inboundCode = ''/)
assert.match(source, /manualInboundCodeRequired\.value[\s\S]*?rows\.findIndex\(\(row\) => !row\.inboundCode\.trim\(\)\)/)
assert.match(source, /请填写第 \$\{missingInboundCodeIndex \+ 1\} 行的旧系统入仓码/)
assert.match(source, /!row\.channelKey \|\| !row\.destinationWarehouseName/)
+16 -4
View File
@@ -318,11 +318,23 @@ async function loadChannels() {
}
}
async function submitQuickOrder() {
if (!inboundCodePolicy.value) {
ElMessage.warning('入仓码规则尚未加载,请刷新页面后重试')
return
async function refreshInboundCodePolicyForWrite() {
try {
const policy = await getMerchantInboundCodePolicy()
inboundCodePolicy.value = policy
if (policy.mode === 'AUTO') {
rows.forEach((row) => { row.inboundCode = '' })
}
return true
} catch (error) {
inboundCodePolicy.value = null
ElMessage.warning(error instanceof Error ? error.message : '入仓码规则加载失败,请稍后重试')
return false
}
}
async function submitQuickOrder() {
if (!await refreshInboundCodePolicyForWrite()) return
const missingInboundCodeIndex = manualInboundCodeRequired.value
? rows.findIndex((row) => !row.inboundCode.trim())
: -1