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 <cursoragent@cursor.com>
This commit is contained in:
zlwuandCursor committed 2026-07-31 06:58:06 +08:00
1 parent 07cadc9025
commit c39c0e2760
1 file changed
+104 -25
@@ -3,7 +3,7 @@
<el-dialog
v-model="innerVisible"
:title="dialogTitle"
width="720px"
width="1080px"
align-center
destroy-on-close
append-to-body
@@ -31,11 +31,11 @@
clearable
/>
</el-form-item>
<el-form-item label="回传备注" class="form-col-span-2">
<el-form-item label="回传备注">
<el-input
v-model="formData.feedbackRemark"
type="textarea"
:rows="3"
:rows="2"
maxlength="500"
show-word-limit
placeholder="回传备注"
@@ -67,6 +67,32 @@
产品 {{ idx + 1 }}/{{ productRows.length }}
</span>
</div>
<div class="pl-driver-feedback-product__meta">
<div class="pl-driver-feedback-product__meta-item">
<span class="pl-driver-feedback-product__meta-label">规格型号</span>
<span class="pl-driver-feedback-product__meta-value">{{ row.model || '—' }}</span>
</div>
<div class="pl-driver-feedback-product__meta-item">
<span class="pl-driver-feedback-product__meta-label">产品分类</span>
<span class="pl-driver-feedback-product__meta-value">{{ row.categoryName || '—' }}</span>
</div>
<div class="pl-driver-feedback-product__meta-item">
<span class="pl-driver-feedback-product__meta-label">单位</span>
<span class="pl-driver-feedback-product__meta-value">{{
row.unitLabel || row.unit || '—'
}}</span>
</div>
<div class="pl-driver-feedback-product__meta-item">
<span class="pl-driver-feedback-product__meta-label">包装规格</span>
<span class="pl-driver-feedback-product__meta-value">{{ row.packageSpec || '—' }}</span>
</div>
<div class="pl-driver-feedback-product__meta-item">
<span class="pl-driver-feedback-product__meta-label">送货方式</span>
<span class="pl-driver-feedback-product__meta-value">{{
getDeliveryMethodLabel(row.deliveryMethod)
}}</span>
</div>
</div>
<div class="pl-driver-feedback-product__actual">
<span class="pl-driver-feedback-product__actual-label">实际数量</span>
<el-input-number
@@ -76,7 +102,6 @@
:controls="false"
:disabled="Boolean(row.brandMode)"
class="pl-driver-feedback-product__actual-input"
@change="() => onActualQtyChange(row)"
/>
<span class="pl-driver-feedback-product__unit">{{ row.unitLabel || row.unit || '吨' }}</span>
</div>
@@ -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<string, BrandOption[]>()
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;