From c39c0e276075c0e7e812b0a91b37a80d5efbffc3 Mon Sep 17 00:00:00 2001 From: zlwu <704541015@qq.com> Date: Fri, 31 Jul 2026 06:58:06 +0800 Subject: [PATCH] fix(web-admin): driver feedback dialog multi-brand for required preference Load full brand options and preselect preferred brand without locking. Co-authored-by: Cursor --- .../pl-plan-driver-feedback-dialog/index.vue | 129 ++++++++++++++---- 1 file changed, 104 insertions(+), 25 deletions(-) diff --git a/web-admin/src/components/business/pl-plan-driver-feedback-dialog/index.vue b/web-admin/src/components/business/pl-plan-driver-feedback-dialog/index.vue index 337d86e7f..022fca699 100644 --- a/web-admin/src/components/business/pl-plan-driver-feedback-dialog/index.vue +++ b/web-admin/src/components/business/pl-plan-driver-feedback-dialog/index.vue @@ -3,7 +3,7 @@ - + +
+
+ 规格型号 + {{ row.model || '—' }} +
+
+ 产品分类 + {{ row.categoryName || '—' }} +
+
+ 单位 + {{ + row.unitLabel || row.unit || '—' + }} +
+
+ 包装规格 + {{ row.packageSpec || '—' }} +
+
+ 送货方式 + {{ + getDeliveryMethodLabel(row.deliveryMethod) + }} +
+
实际数量 {{ row.unitLabel || row.unit || '吨' }}
@@ -128,6 +153,7 @@ import { type PlanProduct, type TransportDriverProductFeedback } from '@/api/pl' +import { getDeliveryMethodLabel } from '@/composables/usePlContractToPlan' import { useDictStore } from '@/store/modules/dict' import { pickBxData } from '@/utils/http/bx' import { parsePlFeedbackImages } from '@/utils/pl-display' @@ -135,6 +161,10 @@ import { parsePlFeedbackImages } from '@/utils/pl-display' interface DriverFeedbackProductRow { planProductId: string productName: string + model: string + categoryName: string + packageSpec: string + deliveryMethod: string unit: string unitLabel: string brandMode?: string @@ -196,12 +226,6 @@ function syncRowActualQty(row: DriverFeedbackProductRow, val: number) { row.actualQty = Number(val) } -function onActualQtyChange(row: DriverFeedbackProductRow) { - if (row.brandMode === 'required' && row.brandQtyRows.length) { - row.brandQtyRows[0].qty = Number(row.actualQty ?? 0) - } -} - function brandQtySum(rows: BrandQtyRow[]) { return rows.reduce((sum, row) => sum + Number(row.qty || 0), 0) } @@ -225,14 +249,14 @@ function mapBrandQtyRows( qty: Number(r.qty) })) if (prod.brandMode === 'required') { - const brandId = prod.brandId || brandOptions[0]?.brandId || '' + if (savedPositive.length) return savedPositive + const brandId = prod.brandId || '' + if (!brandId) return [] const brandName = prod.brandName || - brandOptions.find(o => o.brandId === brandId)?.brandName || + brandOptions.find((o) => o.brandId === brandId)?.brandName || '指定品牌' - if (!brandId) return [] - const saved = savedPositive.find(r => r.brandId === brandId) - return [{ brandId, brandName, qty: saved ? saved.qty : seedActualQty }] + return [{ brandId, brandName, qty: seedActualQty }] } if (prod.brandMode === 'any') { const qtyMap = new Map(savedPositive.map(r => [r.brandId, r.qty])) @@ -293,20 +317,34 @@ async function buildProductRows(plan: Plan, transportFeedbackQty?: number | null const brandOptionMap = new Map() await Promise.all( - [...new Set(products.filter(p => p.brandMode === 'any' && p.productId).map(p => p.productId))].map( - async productId => { - brandOptionMap.set(productId, await loadBrandOptions(productId)) - } - ) + [ + ...new Set( + products + .filter( + (p) => (p.brandMode === 'any' || p.brandMode === 'required') && p.productId + ) + .map((p) => p.productId) + ) + ].map(async (productId) => { + brandOptionMap.set(productId, await loadBrandOptions(productId)) + }) ) productRows.value = products.map(prod => { - const brandOptions = - prod.brandMode === 'any' + let brandOptions = + prod.brandMode === 'any' || prod.brandMode === 'required' ? brandOptionMap.get(prod.productId) || [] - : prod.brandId - ? [{ brandId: prod.brandId, brandName: prod.brandName || '指定品牌' }] - : [] + : [] + if ( + prod.brandMode === 'required' && + prod.brandId && + !brandOptions.some((o) => o.brandId === prod.brandId) + ) { + brandOptions = [ + { brandId: prod.brandId, brandName: prod.brandName || '指定品牌' }, + ...brandOptions + ] + } const savedFeedback = savedByPlanProductId.get(prod.id) || null const seedActualQty = resolveSeedActualQty( prod, @@ -327,6 +365,10 @@ async function buildProductRows(plan: Plan, transportFeedbackQty?: number | null return { planProductId: prod.id, productName: prod.productName || '', + model: prod.model || '', + categoryName: prod.categoryName || '', + packageSpec: prod.packageSpec || '', + deliveryMethod: prod.deliveryMethod || '', unit: prod.unit || '吨', unitLabel: resolveUnitLabel(prod.unit), brandMode: prod.brandMode, @@ -497,6 +539,37 @@ async function handleSubmit() { color: #64748b; } +.pl-driver-feedback-product__meta { + display: grid; + grid-template-columns: repeat(5, minmax(0, 1fr)); + gap: 8px 12px; + margin-bottom: 12px; + padding: 10px 12px; + border-radius: 8px; + background: #fff; + border: 1px solid #e2e8f0; +} + +.pl-driver-feedback-product__meta-item { + display: flex; + flex-direction: column; + gap: 4px; + min-width: 0; +} + +.pl-driver-feedback-product__meta-label { + font-size: 11px; + color: #94a3b8; + line-height: 1.2; +} + +.pl-driver-feedback-product__meta-value { + font-size: 13px; + color: #334155; + line-height: 1.4; + word-break: break-all; +} + .pl-driver-feedback-product__actual { display: grid; grid-template-columns: 72px 1fr auto; @@ -505,6 +578,12 @@ async function handleSubmit() { margin-bottom: 4px; } +@media (max-width: 900px) { + .pl-driver-feedback-product__meta { + grid-template-columns: repeat(2, minmax(0, 1fr)); + } +} + .pl-driver-feedback-product__actual-label { font-size: 13px; color: #64748b;