提交
This commit is contained in:
1 parent
4611dbc2b2
commit
ebf006eeff
46 files changed
+36802
-20974
No files matched your search
@@ -13,10 +13,7 @@
|
||||
|
||||
<section class="pl-plan-form-section pl-plan-form-section--plain">
|
||||
<h3 class="pl-plan-form-section-title">运输信息</h3>
|
||||
<div
|
||||
v-if="showArrangeLinks"
|
||||
class="pl-plan-arrange-links pl-plan-transport-block"
|
||||
>
|
||||
<div v-if="showArrangeLinks" class="pl-plan-arrange-links pl-plan-transport-block">
|
||||
<div class="pl-arrange-links-body">
|
||||
<div class="pl-arrange-link-row">
|
||||
<span class="pl-arrange-link-label">司机链接</span>
|
||||
@@ -123,6 +120,10 @@
|
||||
stop-archive-mode="load"
|
||||
/>
|
||||
<p v-else class="pl-plan-form-empty-hint">暂无装货产品</p>
|
||||
<PlPlanArchiveBrandViewBlock
|
||||
v-if="showArchiveIoFields"
|
||||
:items="loadArchiveBrandItems"
|
||||
/>
|
||||
<PlPlanStopFeedbackPanel
|
||||
v-if="showStopFeedback && !feedbackMirrorTo"
|
||||
stop-label="装货"
|
||||
@@ -136,7 +137,10 @@
|
||||
</div>
|
||||
</template>
|
||||
<template #delivery>
|
||||
<div v-if="deliveryViews.length > 1" class="pl-plan-delivery-tabs pl-plan-view-delivery-tabs">
|
||||
<div
|
||||
v-if="deliveryViews.length > 1"
|
||||
class="pl-plan-delivery-tabs pl-plan-view-delivery-tabs"
|
||||
>
|
||||
<button
|
||||
v-for="(delivery, index) in deliveryViews"
|
||||
:key="delivery.id || 'delivery-tab-' + index"
|
||||
@@ -199,6 +203,10 @@
|
||||
stop-archive-mode="delivery"
|
||||
/>
|
||||
<p v-else class="pl-plan-form-empty-hint">暂无送货产品</p>
|
||||
<PlPlanArchiveBrandViewBlock
|
||||
v-if="showArchiveIoFields"
|
||||
:items="deliveryArchiveBrandItems(delivery, index)"
|
||||
/>
|
||||
<PlPlanStopFeedbackPanel
|
||||
v-if="showStopFeedback && !feedbackMirrorTo"
|
||||
:stop-label="
|
||||
@@ -360,7 +368,12 @@
|
||||
</div>
|
||||
</el-form-item>
|
||||
<el-form-item label="现场备注">
|
||||
<el-input v-model="ioOrderEditForm.siteFeedbackRemark" type="textarea" :rows="3" maxlength="500" />
|
||||
<el-input
|
||||
v-model="ioOrderEditForm.siteFeedbackRemark"
|
||||
type="textarea"
|
||||
:rows="3"
|
||||
maxlength="500"
|
||||
/>
|
||||
</el-form-item>
|
||||
<el-form-item label="现场附件">
|
||||
<AttachmentUploadField v-model="ioOrderEditImagesCsv" />
|
||||
@@ -392,6 +405,7 @@
|
||||
} from '@/components/business/brand-qty-chips-field/index.vue'
|
||||
import PlPlanDriverFeedbackDialog from '@/components/business/pl-plan-driver-feedback-dialog/index.vue'
|
||||
import PlPlanHazardCertViewTable from '@/components/business/pl-plan-hazard-cert-view-table/index.vue'
|
||||
import PlPlanArchiveBrandViewBlock from '@/components/business/pl-plan-archive-brand-view-block/index.vue'
|
||||
import PlPlanStopFeedbackPanel from '@/components/business/pl-plan-stop-feedback-panel/index.vue'
|
||||
import PlPlanStopProductTable from '@/components/business/pl-plan-stop-product-table/index.vue'
|
||||
import PlPlanStopsSplitShell from '@/components/business/pl-plan-stops-split-shell/index.vue'
|
||||
@@ -433,6 +447,7 @@
|
||||
type PlanLoadForm,
|
||||
type PlanStopProductFormRow
|
||||
} from '@/utils/pl-plan-stop-form'
|
||||
import { buildArchiveBrandViewsBySegment } from '@/utils/pl-plan-archive-brand-view'
|
||||
import { resolveFreightUnitLabel } from '@/composables/usePlFreightCalc'
|
||||
import { isHazardProduct } from '@/composables/usePlToxicProductCertCheck'
|
||||
import { useDictStore } from '@/store/modules/dict'
|
||||
@@ -579,8 +594,7 @@
|
||||
{
|
||||
label: '状态',
|
||||
value: statusMap[status] || status,
|
||||
tagType:
|
||||
status === 'completed' ? 'success' : status === 'voided' ? 'info' : 'warning'
|
||||
tagType: status === 'completed' ? 'success' : status === 'voided' ? 'info' : 'warning'
|
||||
},
|
||||
{ label: '计划号', value: ioOrder.value.planNo },
|
||||
{ label: '车牌', value: ioOrder.value.vehicleNo },
|
||||
@@ -608,18 +622,15 @@
|
||||
it.brandId &&
|
||||
!options.some((o) => o.brandId === it.brandId)
|
||||
) {
|
||||
options = [
|
||||
{ brandId: it.brandId, brandName: it.brandName || '指定品牌' },
|
||||
...options
|
||||
]
|
||||
options = [{ brandId: it.brandId, brandName: it.brandName || '指定品牌' }, ...options]
|
||||
}
|
||||
return options
|
||||
}
|
||||
|
||||
function mapIoItemBrandQtyRows(it: PlIoOrder['items'][number]): BrandQtyRow[] {
|
||||
const saved = (it.brandQtys || [])
|
||||
.filter(r => Number(r.qty) > 0)
|
||||
.map(r => ({
|
||||
.filter((r) => Number(r.qty) > 0)
|
||||
.map((r) => ({
|
||||
brandId: r.brandId,
|
||||
brandName: r.brandName || '',
|
||||
qty: Number(r.qty)
|
||||
@@ -639,7 +650,7 @@
|
||||
]
|
||||
}
|
||||
if (it.brandMode === 'any') {
|
||||
return (it.brandOptions || []).map(opt => ({
|
||||
return (it.brandOptions || []).map((opt) => ({
|
||||
brandId: opt.brandId,
|
||||
brandName: opt.brandName || '',
|
||||
qty: 0
|
||||
@@ -650,16 +661,14 @@
|
||||
|
||||
function openIoOrderEditDialog() {
|
||||
if (!ioOrder.value) return
|
||||
const planProductById = new Map((products.value || []).map(p => [p.id, p]))
|
||||
const planProductById = new Map((products.value || []).map((p) => [p.id, p]))
|
||||
ioOrderEditForm.value = {
|
||||
...ioOrder.value,
|
||||
items: (ioOrder.value.items || []).map(it => {
|
||||
items: (ioOrder.value.items || []).map((it) => {
|
||||
const brandOptions = resolveIoBrandOptions(it)
|
||||
const brandQtyRows = mapIoItemBrandQtyRows({ ...it, brandOptions })
|
||||
const actualQty = it.brandMode
|
||||
? Number(
|
||||
brandQtyRows.reduce((sum, r) => sum + Number(r.qty || 0), 0).toFixed(3)
|
||||
)
|
||||
? Number(brandQtyRows.reduce((sum, r) => sum + Number(r.qty || 0), 0).toFixed(3))
|
||||
: it.actualQty
|
||||
const planProduct = planProductById.get(it.planProductId)
|
||||
return {
|
||||
@@ -684,7 +693,7 @@
|
||||
for (const it of items) {
|
||||
if (!it.brandMode) continue
|
||||
const rows = it.brandQtyRows || []
|
||||
const positive = rows.filter(r => Number(r.qty) > 0)
|
||||
const positive = rows.filter((r) => Number(r.qty) > 0)
|
||||
if (!positive.length) {
|
||||
ElMessage.warning(`「${it.productName || '产品'}」请至少填写一个品牌数量`)
|
||||
return
|
||||
@@ -699,18 +708,21 @@
|
||||
ioOrderSaving.value = true
|
||||
try {
|
||||
const images = ioOrderEditImagesCsv.value
|
||||
? ioOrderEditImagesCsv.value.split(',').map(s => s.trim()).filter(Boolean)
|
||||
? ioOrderEditImagesCsv.value
|
||||
.split(',')
|
||||
.map((s) => s.trim())
|
||||
.filter(Boolean)
|
||||
: []
|
||||
await api.patch(ioOrderEditForm.value.id, {
|
||||
siteFeedbackRemark: ioOrderEditForm.value.siteFeedbackRemark,
|
||||
siteFeedbackImages: images,
|
||||
items: items.map(it => ({
|
||||
items: items.map((it) => ({
|
||||
id: it.id,
|
||||
actualQty: Number(it.actualQty ?? 0),
|
||||
brandQtys: it.brandMode
|
||||
? (it.brandQtyRows || [])
|
||||
.filter(r => Number(r.qty) > 0)
|
||||
.map(r => ({
|
||||
.filter((r) => Number(r.qty) > 0)
|
||||
.map((r) => ({
|
||||
brandId: r.brandId,
|
||||
brandName: r.brandName,
|
||||
qty: Number(r.qty)
|
||||
@@ -777,9 +789,13 @@
|
||||
productRows.value = enriched
|
||||
}
|
||||
|
||||
watch([products, contractSnapshot], () => {
|
||||
void refreshProductRows()
|
||||
}, { immediate: true, deep: true })
|
||||
watch(
|
||||
[products, contractSnapshot],
|
||||
() => {
|
||||
void refreshProductRows()
|
||||
},
|
||||
{ immediate: true, deep: true }
|
||||
)
|
||||
|
||||
const planProductById = computed(() => {
|
||||
const map = new Map<string, (typeof products.value)[number]>()
|
||||
@@ -797,7 +813,9 @@
|
||||
return map
|
||||
})
|
||||
|
||||
function resolveFeedbackPlanProductId(row: TransportDriverProductFeedback | Record<string, unknown>) {
|
||||
function resolveFeedbackPlanProductId(
|
||||
row: TransportDriverProductFeedback | Record<string, unknown>
|
||||
) {
|
||||
const raw =
|
||||
(row as TransportDriverProductFeedback).planProductId ||
|
||||
(row as { plan_product_id?: string }).plan_product_id ||
|
||||
@@ -873,7 +891,9 @@
|
||||
const fb = feedbackById.get(String(pp.id))
|
||||
if (!fb) continue
|
||||
usedIds.add(String(pp.id))
|
||||
rows.push(buildDriverFeedbackDisplayRow(pp, fb, planProductFormById.value.get(String(pp.id))))
|
||||
rows.push(
|
||||
buildDriverFeedbackDisplayRow(pp, fb, planProductFormById.value.get(String(pp.id)))
|
||||
)
|
||||
}
|
||||
|
||||
// 兼容:planProductId 对不上时按序号兜底
|
||||
@@ -891,7 +911,9 @@
|
||||
const id = resolveFeedbackPlanProductId(fb)
|
||||
if (id && usedIds.has(id)) continue
|
||||
const pp = id ? planProductById.value.get(id) : undefined
|
||||
rows.push(buildDriverFeedbackDisplayRow(pp, fb, id ? planProductFormById.value.get(id) : undefined))
|
||||
rows.push(
|
||||
buildDriverFeedbackDisplayRow(pp, fb, id ? planProductFormById.value.get(id) : undefined)
|
||||
)
|
||||
}
|
||||
return rows
|
||||
}
|
||||
@@ -963,8 +985,7 @@
|
||||
String(formRow?.productNo || '').trim(),
|
||||
String(pp?.productNo || '').trim()
|
||||
].filter(Boolean)
|
||||
const productNo =
|
||||
candidates.find((no) => no && no !== productId) || candidates[0] || ''
|
||||
const productNo = candidates.find((no) => no && no !== productId) || candidates[0] || ''
|
||||
const brandLabel = resolveDisplayBrandLabel({
|
||||
brandMode: it.brandMode || pp?.brandMode || formRow?.brandMode,
|
||||
brandName: it.brandName || pp?.brandName || formRow?.brandName
|
||||
@@ -986,10 +1007,7 @@
|
||||
remark: (it.remark || pp?.remark || formRow?.remark || '').trim(),
|
||||
unit: unitCode || it.unit,
|
||||
unitLabel:
|
||||
it.unitLabel ||
|
||||
dictStore.getLabel('crm_product_unit', unitCode) ||
|
||||
unitCode ||
|
||||
''
|
||||
it.unitLabel || dictStore.getLabel('crm_product_unit', unitCode) || unitCode || ''
|
||||
}
|
||||
})
|
||||
})
|
||||
@@ -1006,7 +1024,7 @@
|
||||
)
|
||||
|
||||
const dibangPlanRows = computed(() =>
|
||||
dibangRows.value.filter(row => Boolean(row.link.dbPurchasePlanId?.trim()))
|
||||
dibangRows.value.filter((row) => Boolean(row.link.dbPurchasePlanId?.trim()))
|
||||
)
|
||||
|
||||
const siteInventoryRows = computed(() => siteRows.value)
|
||||
@@ -1169,11 +1187,15 @@
|
||||
ElMessage.warning('暂无现场链接')
|
||||
return
|
||||
}
|
||||
const product = products.value.find(item => item.id === row.link.planProductId)
|
||||
const product = products.value.find((item) => item.id === row.link.planProductId)
|
||||
const productText = product
|
||||
? formatPlanProductListText(product, unit => dictStore.getLabel('crm_product_unit', unit) || unit, {
|
||||
usePlannedQuantity: true
|
||||
})
|
||||
? formatPlanProductListText(
|
||||
product,
|
||||
(unit) => dictStore.getLabel('crm_product_unit', unit) || unit,
|
||||
{
|
||||
usePlannedQuantity: true
|
||||
}
|
||||
)
|
||||
: row.link.productName || '—'
|
||||
const text = buildSiteSummaryFromInventoryLinks({
|
||||
planNo: row.link.planNo || plan.value?.planNo,
|
||||
@@ -1212,12 +1234,14 @@
|
||||
|
||||
const deliveryViews = computed(() => {
|
||||
if (plan.value?.deliveries?.length) {
|
||||
return mapDeliveriesFromApi(plan.value.deliveries, plan.value.load?.customerName).map((row, index) => ({
|
||||
id: plan.value?.deliveries?.[index]?.id,
|
||||
...row,
|
||||
address: resolveDeliveryViewAddress(plan.value, row, index),
|
||||
products: resolveStopProductsForView(row.products, productRows.value)
|
||||
}))
|
||||
return mapDeliveriesFromApi(plan.value.deliveries, plan.value.load?.customerName).map(
|
||||
(row, index) => ({
|
||||
id: plan.value?.deliveries?.[index]?.id,
|
||||
...row,
|
||||
address: resolveDeliveryViewAddress(plan.value, row, index),
|
||||
products: resolveStopProductsForView(row.products, productRows.value)
|
||||
})
|
||||
)
|
||||
}
|
||||
return mapLegacyPlanToStops(plan.value || ({} as any)).deliveries.map((row, index) => ({
|
||||
id: undefined as string | undefined,
|
||||
@@ -1227,6 +1251,23 @@
|
||||
}))
|
||||
})
|
||||
|
||||
const archiveBrandViewsBySegment = computed(() =>
|
||||
buildArchiveBrandViewsBySegment({
|
||||
loadProducts: loadView.value.products || [],
|
||||
deliveries: deliveryViews.value.map((row, index) => ({
|
||||
key: `delivery-${row.id || index}`,
|
||||
products: row.products || []
|
||||
})),
|
||||
planProducts: productRows.value
|
||||
})
|
||||
)
|
||||
|
||||
const loadArchiveBrandItems = computed(() => archiveBrandViewsBySegment.value.get('load') || [])
|
||||
|
||||
function deliveryArchiveBrandItems(delivery: { id?: string }, index: number) {
|
||||
return archiveBrandViewsBySegment.value.get(`delivery-${delivery.id || index}`) || []
|
||||
}
|
||||
|
||||
watch(
|
||||
() => deliveryViews.value.length,
|
||||
(len) => {
|
||||
@@ -1337,7 +1378,6 @@
|
||||
() => plan.value?.transportStatus === 'arranged' && plan.value?.followStatus !== 'cancelled'
|
||||
)
|
||||
|
||||
|
||||
const feedbackBlocksBind = computed(() => ({
|
||||
feedbackEditable: props.feedbackEditable,
|
||||
showArchiveIoFields: props.showArchiveIoFields,
|
||||
@@ -1405,10 +1445,7 @@
|
||||
const qty = (transport.value as Transport & { transportQty?: number })?.transportQty
|
||||
if (qty != null) return String(qty)
|
||||
if (!productRows.value.length) return '—'
|
||||
const sum = productRows.value.reduce(
|
||||
(total, item) => total + Number(item.actualQty ?? 0),
|
||||
0
|
||||
)
|
||||
const sum = productRows.value.reduce((total, item) => total + Number(item.actualQty ?? 0), 0)
|
||||
return sum ? String(sum) : '—'
|
||||
})
|
||||
|
||||
|
||||
Reference in new issue
Block a user