fix: 统一计划产品计量单位并兼容历史吨单位,避免保存时关联校验失败。

This commit is contained in:
wuzilong committed 2026-10-29 16:16:25 +08:00
1 parent 75d7da3d3d
commit 6f4d4d2c59
10 files changed
+16078 -36329

No files matched your search

+7 -6
View File
@@ -2,6 +2,7 @@ import type { Plan, PlanContractLink, PlanDelivery, PlanLoad, PlanStopProduct }
import type { PlanFormProductRow } from '@/composables/usePlContractToPlan'
import type { BrandOption } from '@/utils/crm-product-brand'
import { formatBrandConstraintLabel } from '@/utils/crm-product-brand'
import { normalizeProductUnitValue } from '@/utils/crm-product-display'
import {
isPlDibangOptionalVehiclePlate,
isPlInternalCustomerName
@@ -193,7 +194,7 @@ export function createStopProductsFromPlanProducts(
brandName: item.brandName,
brandOptions: item.brandOptions ? [...item.brandOptions] : undefined,
model: item.model,
unit: item.unit || '吨',
unit: normalizeProductUnitValue(item.unit),
packageSpec: item.packageSpec,
deliveryMethod: item.deliveryMethod,
planQty: Number(item[qtyField] ?? item.quantity ?? 0),
@@ -399,7 +400,7 @@ export function enrichStopProductsDisplayFromPlan(
brandName: match.brandName ?? row.brandName,
brandOptions: match.brandOptions?.length ? [...match.brandOptions] : row.brandOptions,
model: row.model || match.model,
unit: row.unit || match.unit || '吨',
unit: normalizeProductUnitValue(row.unit || match.unit),
packageSpec: row.packageSpec || match.packageSpec,
deliveryMethod: row.deliveryMethod || match.deliveryMethod,
planQty,
@@ -461,7 +462,7 @@ function mapStopProductFromApi(row: PlanStopProduct): PlanStopProductFormRow {
productNo: row.productNo,
productName: row.productName,
model: row.model,
unit: row.unit || '吨',
unit: normalizeProductUnitValue(row.unit),
packageSpec: row.packageSpec,
deliveryMethod: row.deliveryMethod,
contractId: row.contractId,
@@ -595,7 +596,7 @@ export function mapLegacyPlanToStops(plan: Plan): {
productNo: item.productNo || '',
productName: item.productName || '',
model: item.model,
unit: item.unit || '吨',
unit: normalizeProductUnitValue(item.unit),
quantity: Number(item.quantity ?? item.actualQty ?? 0),
packageSpec: item.packageSpec,
deliveryMethod: item.deliveryMethod,
@@ -754,7 +755,7 @@ export function mapLoadProductsToPlanFormRows(
brandName: row.brandName,
brandOptions: row.brandOptions ? [...row.brandOptions] : undefined,
model: row.model,
unit: row.unit || '吨',
unit: normalizeProductUnitValue(row.unit),
quantity: Number(row.planQty ?? 0),
actualQty: 0,
packageSpec: row.packageSpec,
@@ -863,7 +864,7 @@ export function buildStopProductPayload(row: PlanStopProductFormRow) {
productNo: row.productNo,
productName: row.productName,
model: row.model,
unit: row.unit,
unit: normalizeProductUnitValue(row.unit),
packageSpec: row.packageSpec,
deliveryMethod: row.deliveryMethod,
contractId: row.contractId || undefined,