fix: 订单称重/复核/波次/运单面板 - 重量单位 kg 改为 g

This commit is contained in:
liufumingren 2026-07-27 04:53:48 +08:00
parent 623150288e
commit 15f096b7c1
7 changed files with 24 additions and 57 deletions

View File

@ -16,7 +16,7 @@
</el-table-column>
<el-table-column prop="logistics_name" label="物流公司" min-width="120" show-overflow-tooltip />
<el-table-column prop="logistics_interface_name" label="快递接口" min-width="120" show-overflow-tooltip />
<el-table-column label="称重(kg)" width="110" align="right">
<el-table-column label="称重(g)" width="110" align="right">
<template #default="{ row }">
{{ formatWeight(row.weighing_weight) }}
</template>
@ -46,7 +46,7 @@
<el-form-item label="运单号">
<el-input :model-value="weighingForm.waybill_code" disabled />
</el-form-item>
<el-form-item label="称重(kg)">
<el-form-item label="称重(g)">
<el-input-number
v-model="weighingForm.weighing_weight"
:min="0.001"
@ -101,7 +101,7 @@ const orderId = computed(() => props.row?.id)
function formatWeight(value: unknown) {
if (value === null || value === undefined || value === '') return '—'
const num = Number(value)
return Number.isFinite(num) ? String(num) : String(value)
return Number.isFinite(num) ? String(num) + 'g' : String(value)
}
function formatTime(value: unknown) {

View File

@ -43,7 +43,7 @@
<el-table :data="expresses" border stripe size="small" empty-text="暂无运单信息">
<el-table-column prop="waybill_code" label="运单号" min-width="180" show-overflow-tooltip />
<el-table-column prop="logistics_name" label="物流公司" min-width="140" show-overflow-tooltip />
<el-table-column label="称重(kg)" width="100" align="right">
<el-table-column label="称重(g)" width="100" align="right">
<template #default="{ row }">
{{ formatWeight(row.weighing_weight) }}
</template>
@ -97,7 +97,7 @@ function formatAmount(value: unknown) {
function formatWeight(value: unknown) {
if (value === null || value === undefined || value === '') return '—'
const num = Number(value)
return Number.isFinite(num) ? String(num) : String(value)
return Number.isFinite(num) ? String(num) + 'g' : String(value)
}
function formatExpressTime(value: unknown) {

View File

@ -14,7 +14,7 @@
class="weighing-form-alert"
>
<template #title>
支持运单号模式(order_id=0)与订单模式(order_id 为正整数)。称重重量单位为 kg,须大于 0,最多 3 位小数。
支持运单号模式(order_id=0)与订单模式(order_id 为正整数)。称重重量单位为 g,须大于 0 的整数。
</template>
</el-alert> -->
@ -66,19 +66,12 @@
</el-form-item>
</template>
<el-form-item label="重量单位">
<el-radio-group v-model="formModel.weight_unit">
<el-radio value="kg">kg</el-radio>
<el-radio value="g">g</el-radio>
</el-radio-group>
</el-form-item>
<el-form-item label="称重重量" prop="weighing_weight">
<el-form-item label="称重重量(g)" prop="weighing_weight">
<el-input-number
v-model="formModel.weighing_weight"
:min="formModel.weight_unit === 'g' ? 1 : 0.001"
:precision="formModel.weight_unit === 'g' ? 0 : 3"
:step="formModel.weight_unit === 'g' ? 1 : 0.1"
:min="1"
:precision="0"
:step="1"
controls-position="right"
placeholder="请输入称重重量"
style="width: 100%"
@ -126,7 +119,6 @@ const formModel = reactive({
waybill_code: '',
order_id: undefined as number | undefined,
order_waybill_code: '',
weight_unit: 'kg' as 'kg' | 'g',
weighing_weight: undefined as number | undefined
})
@ -136,12 +128,9 @@ function validateWeighingWeight(_rule: unknown, value: unknown, callback: (error
callback(new Error('称重重量须大于 0'))
return
}
if (formModel.weight_unit === 'kg') {
const rounded = Number(num.toFixed(3))
if (Math.abs(num - rounded) > 1e-9) {
callback(new Error('kg 单位最多 3 位小数'))
return
}
if (!Number.isInteger(num)) {
callback(new Error('称重重量必须为整数(g)'))
return
}
callback()
}
@ -192,34 +181,12 @@ function resetForm() {
formModel.waybill_code = props.initialWaybillCode?.trim() || ''
formModel.order_id = undefined
formModel.order_waybill_code = ''
formModel.weight_unit = loadWeightUnit()
formModel.weighing_weight = undefined
formRef.value?.clearValidate()
}
function loadWeightUnit(): 'kg' | 'g' {
try {
const unit = localStorage.getItem('order_weighing_unit')
return unit === 'g' ? 'g' : 'kg'
} catch {
return 'kg'
}
}
function saveWeightUnit(unit: 'kg' | 'g') {
try {
localStorage.setItem('order_weighing_unit', unit)
} catch {
/* ignore */
}
}
function buildPayload(): UpdateExpressWeighingWeightParams {
const rawWeight = Number(formModel.weighing_weight)
const weighingWeight =
formModel.weight_unit === 'g'
? Number((rawWeight / 1000).toFixed(3))
: Number(rawWeight.toFixed(3))
const weighingWeight = Number(formModel.weighing_weight)
if (formModel.weighing_mode === 'waybill') {
return {
@ -257,7 +224,7 @@ async function handleSubmit() {
if (!isOrderIndexApiSuccess(res)) {
throw new Error(res?.message || '称重保存失败')
}
saveWeightUnit(formModel.weight_unit)
const detail = parseUpdateExpressWeighingWeightResponse(res)
ElMessage.success(res?.message || '称重保存成功')
applySuccessResult(payload, detail)

View File

@ -9,11 +9,11 @@
<div class="result-title">{{ lastResult.wave_no || lastResult.waybill || '称重结果' }}</div>
<div class="result-weights">
<div class="weight-row">
<el-tag size="default" :type="weightWarnType" class="weight-tag">{{ lastResult.weighing_weight }} kg</el-tag>
<el-tag size="default" :type="weightWarnType" class="weight-tag">{{ lastResult.weighing_weight }} g</el-tag>
<span class="weight-label">称重</span>
</div>
<div class="weight-row" v-if="lastResult.total_weight != null">
<el-tag size="default" type="info" class="weight-tag">{{ lastResult.total_weight }} kg</el-tag>
<el-tag size="default" type="info" class="weight-tag">{{ lastResult.total_weight }} g</el-tag>
<span class="weight-label">系统</span>
</div>
</div>
@ -40,7 +40,7 @@
:class="{ 'has-waybill': s.waybill_code }"
>
<span class="split-key">{{ s.business_key }}</span>
<span class="split-weight">{{ s.weighing_weight }} kg</span>
<span class="split-weight">{{ s.weighing_weight }} g</span>
<span class="split-waybill" v-if="s.waybill_code">{{ s.waybill_code }}</span>
<span class="split-waybill empty" v-else>待分配</span>
</div>
@ -88,7 +88,7 @@
@refresh="loadList"
>
<template #column-weighing_weight="{ row }">
<span v-if="row.weighing_weight != null">{{ row.weighing_weight }} kg</span>
<span v-if="row.weighing_weight != null">{{ row.weighing_weight }} g</span>
<span v-else style="color:#c0c4cc">未称重</span>
</template>

View File

@ -178,7 +178,7 @@
@closed="resetWeighingForm"
>
<el-form ref="weighingFormRef" :model="weighingForm" :rules="weighingRules" label-width="80px" @submit.prevent>
<el-form-item label="重量" prop="weight">
<el-form-item label="重量(g)" prop="weight">
<el-input-number
ref="weighingInputRef"
v-model="weighingForm.weight"
@ -187,7 +187,7 @@
:precision="3"
:step="0.001"
style="width: 100%"
placeholder="请输入重量(kg)"
placeholder="请输入重量(g)"
@keyup.enter.prevent="submitWeighing"
/>
</el-form-item>
@ -1769,7 +1769,7 @@ async function submitWeighing() {
payload.recheck_status,
payload.recheck_time
].filter((x) => x != null && String(x) !== '')
ElMessage.success(parts.length ? `复核成功:${parts.join(' / ')},称重 ${weight} kg` : `复核已记录,称重 ${weight} kg`)
ElMessage.success(parts.length ? `复核成功:${parts.join(' / ')},称重 ${weight} g` : `复核已记录,称重 ${weight} g`)
weighingDialogVisible.value = false
weighingBeforeConfirm.value = false
await finishConfirmAndAdvance()

View File

@ -17,7 +17,7 @@ export const recheckOrderSingleListColumns = [
{ prop: 'recheck_status', label: '复核状态', width: '96' },
{ prop: 'items_count', label: 'SKU数', width: '72', align: 'right' },
{ prop: 'items_total', label: '件数', width: '72', align: 'right' },
{ prop: 'items_weight', label: '重量', width: '80', align: 'right' },
{ prop: 'items_weight', label: '重量(g)', width: '80', align: 'right' },
{ prop: 'pick_time', label: '拣货时间', width: '150' },
{ prop: 'recheck_time', label: '复核时间', width: '150' }
]

View File

@ -249,7 +249,7 @@ export const fallbackOrderColumns = applyWaveListCopyActions([
{ prop: 'province', label: '省份', minWidth: 100 },
{ prop: 'items_count', label: '商品种数', minWidth: 100 },
{ prop: 'items_total', label: '商品总数', minWidth: 100 },
{ prop: 'items_weight', label: '商品重量kg', minWidth: 110 },
{ prop: 'items_weight', label: '商品重量(g)', minWidth: 110 },
{ prop: 'item_snapshot', label: '商品快照', minWidth: 260 },
{ prop: 'wave_scan_result', label: '扫描结果', minWidth: 110 },
{ prop: 'buyer_message', label: '买家留言', minWidth: 180 },