优化
This commit is contained in:
@@ -45,6 +45,8 @@ const weightDrafts = ref<Record<string, { value: number | null; unit: 'KG' | 'LB
|
||||
let loadSequence = 0
|
||||
|
||||
const editableStatuses = new Set(['WAIT_MEASURE', 'MEASURING', 'MEASURE_REJECTED'])
|
||||
const minimumWeight = { KG: 0.001, LB: 0.002 } as const
|
||||
const maximumSafeWeight = 9_000_000_000_000
|
||||
const customerId = computed(() => props.customerId || props.tenantId || '')
|
||||
const canEdit = computed(() => access.can('platform:firstleg:inbound:weight:edit'))
|
||||
const canConfirm = computed(() => access.can('platform:firstleg:inbound:weight:confirm'))
|
||||
@@ -83,7 +85,11 @@ function isActionLoading(action: string, id: string) {
|
||||
}
|
||||
|
||||
function normalizeUnit(value: string | null) {
|
||||
return value?.toUpperCase().startsWith('LB') ? 'LB' as const : 'KG' as const
|
||||
return value?.trim().toUpperCase().startsWith('LB') ? 'LB' as const : 'KG' as const
|
||||
}
|
||||
|
||||
function isSupportedUnit(value: string | null) {
|
||||
return ['KG', 'KGS', 'LB', 'LBS'].includes(value?.trim().toUpperCase() || '')
|
||||
}
|
||||
|
||||
function syncWeightDrafts(results: WeightResultResource[]) {
|
||||
@@ -95,21 +101,30 @@ function syncWeightDrafts(results: WeightResultResource[]) {
|
||||
|
||||
function isWeightDraftValid(row: WeightResultResource) {
|
||||
const draft = weightDrafts.value[row.id]
|
||||
return Boolean(draft && Number.isFinite(Number(draft.value)) && Number(draft.value) > 0)
|
||||
const value = Number(draft?.value)
|
||||
return Boolean(draft
|
||||
&& Number.isFinite(value)
|
||||
&& value >= minimumWeight[draft.unit]
|
||||
&& value <= maximumSafeWeight)
|
||||
}
|
||||
|
||||
function hasWeightDraftChanged(row: WeightResultResource) {
|
||||
const draft = weightDrafts.value[row.id]
|
||||
if (!draft) return false
|
||||
const savedValue = row.adjustedWeightValue ?? row.ocrWeightValue
|
||||
const savedUnit = normalizeUnit(row.adjustedWeightUnit ?? row.ocrWeightUnit)
|
||||
const rawSavedUnit = row.adjustedWeightUnit ?? row.ocrWeightUnit
|
||||
const savedUnit = normalizeUnit(rawSavedUnit)
|
||||
if (!isSupportedUnit(rawSavedUnit)) return true
|
||||
return Number(draft.value) !== Number(savedValue) || draft.unit !== savedUnit
|
||||
}
|
||||
|
||||
function buildAdjustmentReason(row: WeightResultResource) {
|
||||
const draft = weightDrafts.value[row.id]
|
||||
const ocrUnit = normalizeUnit(row.ocrWeightUnit)
|
||||
return `OCR 原值 ${formatWeight(row.ocrWeightValue, ocrUnit)},人工确认 ${formatWeight(Number(draft.value), draft.unit)}`
|
||||
const ocrUnit = row.ocrWeightUnit?.trim().toUpperCase()
|
||||
const ocrValue = row.ocrWeightValue == null
|
||||
? '—'
|
||||
: `${Number(row.ocrWeightValue).toFixed(3)}${ocrUnit ? ` ${ocrUnit}` : '(单位缺失)'}`
|
||||
return `OCR 原值 ${ocrValue},人工确认 ${formatWeight(Number(draft.value), draft.unit)}`
|
||||
}
|
||||
|
||||
async function loadWorkspace() {
|
||||
@@ -390,8 +405,8 @@ defineExpose({ reload: loadWorkspace })
|
||||
<el-input-number
|
||||
v-model="weightDrafts[row.id].value"
|
||||
:aria-label="`称重图片序号 ${index + 1} 的确认重量`"
|
||||
:min="0.001"
|
||||
:max="999999999999999.999"
|
||||
:min="minimumWeight[weightDrafts[row.id].unit]"
|
||||
:max="maximumSafeWeight"
|
||||
:precision="3"
|
||||
:controls="false"
|
||||
:disabled="Boolean(activeAction) || !editable || !canEdit || !canConfirm"
|
||||
|
||||
Reference in New Issue
Block a user