fix: 库存/收货/包材 - 重量单位添加 g 标注及整数校验

This commit is contained in:
liufumingren 2026-07-27 04:53:53 +08:00
parent 15f096b7c1
commit 2e5093ddd2
8 changed files with 32 additions and 15 deletions

View File

@ -54,7 +54,7 @@
{{ formatCellNumber(row.height) }}
</template>
<template #column-weight="{ row }">
{{ formatCellNumber(row.weight) }}
{{ formatCellNumber(row.weight) ? formatCellNumber(row.weight) + 'g' : '--' }}
</template>
<template #column-cost_price="{ row }">
{{ formatCellNumber(row.cost_price) }}
@ -129,7 +129,7 @@ const previewColumns = [
{ prop: 'length', label: '长度', width: '80' },
{ prop: 'width', label: '宽度', width: '80' },
{ prop: 'height', label: '高度', width: '80' },
{ prop: 'weight', label: '重量', width: '80' },
{ prop: 'weight', label: '重量(g)', width: '80' },
{ prop: 'cost_price', label: '成本价', width: '90' },
{ prop: 'status', label: '状态', width: '70' },
{ prop: 'import_status', label: '导入状态', width: '100' },

View File

@ -59,7 +59,7 @@
</template>
<template #column-weight="{ row }">
{{ formatNumber(row.weight) }}
{{ formatNumber(row.weight) ? formatNumber(row.weight) + 'g' : '--' }}
</template>
<template #column-cost_price="{ row }">
@ -152,7 +152,7 @@
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item label="重量" prop="weight">
<el-form-item label="重量(g)" prop="weight">
<el-input-number
v-model="formData.weight"
:min="0"

View File

@ -21,7 +21,7 @@ export const packageMaterialColumns = [
{ prop: 'material_type', label: '包材类型', minWidth: '110', showOverflowTooltip: true },
{ prop: 'spec', label: '规格', minWidth: '120', showOverflowTooltip: true },
{ prop: 'dimensions', label: '尺寸(L×W×H)', minWidth: '140' },
{ prop: 'weight', label: '重量', width: '90' },
{ prop: 'weight', label: '重量(g)', width: '90' },
{ prop: 'cost_price', label: '成本价', width: '100' },
{ prop: 'status', label: '状态', width: '90' },
{ prop: 'actions', label: '操作', width: '150', fixed: 'right' }

View File

@ -124,7 +124,7 @@
<el-descriptions-item label="商家编码">{{ selectedRow.goods_code || '—' }}</el-descriptions-item>
<el-descriptions-item label="品牌">{{ selectedRow.brand_name || '—' }}</el-descriptions-item>
<el-descriptions-item label="库存单位">{{ selectedRow.stock_unit || '—' }}</el-descriptions-item>
<el-descriptions-item label="毛重">{{ selectedRow.gross_weight ?? '—' }}</el-descriptions-item>
<el-descriptions-item label="毛重">{{ selectedRow.gross_weight != null ? selectedRow.gross_weight + 'g' : '—' }}</el-descriptions-item>
<el-descriptions-item label="条码" :span="2">
<template v-if="selectedRow.barcodes && selectedRow.barcodes.length">
<el-tag

View File

@ -78,7 +78,7 @@ export const stockColumns = [
},
{
prop: 'gross_weight',
label: '毛重',
label: '毛重(g)',
width: '100',
formatter: (row: any) => row.gross_weight ? `${formatNumber(row.gross_weight, 0)}g` : '--'
},
@ -212,7 +212,7 @@ export const stockColumns = [
},
{
prop: 'net_weight',
label: '净重',
label: '净重(g)',
width: '100',
formatter: (row: any) => row.net_weight ? `${formatNumber(row.net_weight, 0)}g` : '--'
},
@ -507,6 +507,11 @@ export const stockFormRules = {
stock_unit: [{ required: true, message: '库存单位不能为空', trigger: 'change' }],
gross_weight: [
{ required: true, message: '毛重不能为空', trigger: 'blur' },
{
pattern: /^(0|[1-9]\d*)$/,
message: '毛重必须为非负整数(g)',
trigger: 'blur'
},
{
validator: (rule: any, value: any, callback: any) => {
if (value < 0) callback(new Error('毛重不能小于0'))

View File

@ -238,7 +238,7 @@
</el-input>
</el-form-item>
</el-col>
<el-col :span="12"><el-form-item label="毛重/重量"><el-input v-model="editForm.weight" clearable /></el-form-item></el-col>
<el-col :span="12"><el-form-item label="毛重/重量(g)"><el-input-number v-model="editForm.weight" :min="0" :precision="0" :controls="false" style="width: 100%" /></el-form-item></el-col>
<el-col :span="12">
<el-form-item label="SKU">
@ -265,7 +265,7 @@
<el-col :span="12"><el-form-item label="箱长"><el-input v-model="editForm.box_length" clearable /></el-form-item></el-col>
<el-col :span="12"><el-form-item label="箱宽"><el-input v-model="editForm.box_width" clearable /></el-form-item></el-col>
<el-col :span="12"><el-form-item label="箱高"><el-input v-model="editForm.box_height" clearable /></el-form-item></el-col>
<el-col :span="12"><el-form-item label="实测箱重"><el-input v-model="editForm.box_weight" clearable /></el-form-item></el-col>
<el-col :span="12"><el-form-item label="实测箱重(g)"><el-input-number v-model="editForm.box_weight" :min="0" :precision="0" :controls="false" style="width: 100%" /></el-form-item></el-col>
<el-col :span="24"><el-form-item label="备注"><el-input v-model="editForm.remark" type="textarea" :rows="3" clearable /></el-form-item></el-col>
</el-row>
@ -337,7 +337,7 @@
{ prop: 'item_name', label: '商品名称', minWidth: '220' },
{ prop: 'barcodes', label: '条码', width: '180' },
{ prop: 'store_name', label: '货主', width: '180' },
{ prop: 'weight', label: '重量', width: '110', align: 'right' }
{ prop: 'weight', label: '重量(g)', width: '110', align: 'right' }
]"
@selection-change="handleSystemProductSelectionChange"
@row-click="handleSystemProductRowClick"
@ -2213,6 +2213,18 @@ const submitEditDetail = async () => {
const itemPayload: any = {}
// 重量字段必须为整数(g)
for (const wf of ['weight', 'box_weight'] as const) {
const raw = editForm[wf]
if (raw !== '' && raw !== null && raw !== undefined) {
const n = Number(raw)
if (!Number.isInteger(n) || n < 0) {
ElMessage.warning(`${wf === 'weight' ? '毛重/重量' : '实测箱重'}必须为非负整数(g)`)
return
}
}
}
const numberFields = [
'actual_quantity',
'box_quantity',

View File

@ -1526,7 +1526,7 @@ async function handleExport(mode: 'waybill' | 'item' = 'waybill') {
'实收数量': item.actual_quantity ?? '',
'箱数': item.box_quantity ?? '',
'箱规': item.boxes_per_pallet ?? '',
'重量': item.weight ?? '',
'重量(g)': item.weight ?? '',
'批次号': item.batch_number || '',
'生产日期': item.production_date || '',
'有效期': item.expiry_date || '',

View File

@ -406,7 +406,7 @@ export const productdetail = [
{ prop: 'actual_quantity', label: '实际收货数量', width: '160' },
{ prop: 'box_quantity', label: '箱数', width: '160' },
{ prop: 'boxes_per_pallet', label: '箱规', width: '160' },
{ prop: 'weight', label: '重量', width: '160' },
{ prop: 'weight', label: '重量(g)', width: '160' },
{ prop: 'pallet_quantity', label: '托盘数', width: '160' },
{ prop: 'receiving_time', label: '收货时间', width: '160' },
{ prop: 'receiving_status', label: '收货状态', width: '160' },
@ -445,7 +445,7 @@ export const productquick = [
{ prop: 'actual_quantity', label: '收货数量', width: '100', align: 'right' },
{ prop: 'box_quantity', label: '箱数', width: '100', align: 'right' },
{ prop: 'boxes_per_pallet', label: '箱规', width: '100', align: 'right' },
{ prop: 'weight', label: '重量', width: '100', align: 'right' },
{ prop: 'weight', label: '重量(g)', width: '100', align: 'right' },
{ prop: 'batch_number', label: '批次号', width: '120' },
{ prop: 'production_date', label: '生产日期', width: '120' },
{ prop: 'expiry_date', label: '到期日期', width: '120' },
@ -495,7 +495,7 @@ export const printFormConfig = [
{ prop: 'barcode', label: '商品条码', type: 'input' },
{ prop: 'box_quantity', label: '箱数', type: 'number' },
{ prop: 'boxes_per_pallet', label: '箱规', type: 'number' },
{ prop: 'weight', label: '重量', type: 'number' },
{ prop: 'weight', label: '重量(g)', type: 'number' },
{ prop: 'actual_quantity', label: '实际收货数量', type: 'number' },
{ prop: 'remark', label: '明细备注', type: 'input' },
]}