feat(web-admin): show brand qty on transport tab and highlight supplement actions
Expose driver per-product feedback on transport read, display site/driver brand summaries in the transport tab, move supplement buttons to section headers with primary highlight, and wire brand chips into IO/driver edit. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
1 parent
b7236329c2
commit
5c323f32c2
7 files changed
+510
-118
No files matched your search
@@ -40,6 +40,7 @@ from app.schemas.pl.transport import (
|
||||
TransportSiteLinkRead,
|
||||
TransportListQuery,
|
||||
TransportListResponse,
|
||||
TransportDriverProductFeedbackRead,
|
||||
TransportRead,
|
||||
)
|
||||
from app.services.pl_dibang_bridge_service import (
|
||||
@@ -50,6 +51,7 @@ from app.services.pl_inventory_link_read import build_transport_inventory_link_r
|
||||
from app.services.pl_io_order_service import (
|
||||
apply_dibang_prefill_to_order,
|
||||
create_io_order_for_transport,
|
||||
void_io_orders_for_plan,
|
||||
)
|
||||
from app.services.pl_plan_service import (
|
||||
is_ton_product_unit,
|
||||
@@ -60,10 +62,30 @@ from app.services.pl_transport_resource_snapshot_service import (
|
||||
build_transport_resource_snapshot,
|
||||
)
|
||||
from app.services.pl_carrier_service import assert_carrier_eligible_for_transport
|
||||
from app.services.pl_feedback_brand_qty import load_transport_driver_product_feedbacks
|
||||
|
||||
router = APIRouter(prefix="/order", tags=["运输计划-运输管理"])
|
||||
|
||||
|
||||
def _transport_to_read(db: Session, transport: PlTransport) -> TransportRead:
|
||||
base = TransportRead.model_validate(transport)
|
||||
feedbacks = load_transport_driver_product_feedbacks(
|
||||
db,
|
||||
tenant_no=transport.tenant_no,
|
||||
transport_id=transport.id,
|
||||
)
|
||||
if not feedbacks:
|
||||
return base
|
||||
return base.model_copy(
|
||||
update={
|
||||
"driver_product_feedbacks": [
|
||||
TransportDriverProductFeedbackRead.model_validate(item)
|
||||
for item in feedbacks
|
||||
]
|
||||
}
|
||||
)
|
||||
|
||||
|
||||
def _generate_transport_no(db: Session) -> str:
|
||||
"""生成运输编号 SXYS######"""
|
||||
now = date.today()
|
||||
@@ -227,7 +249,7 @@ def _is_rearrange(plan: PlPlan, existing_transport: Optional[PlTransport]) -> bo
|
||||
"""仅计划已正式安排才算「调整运输」。
|
||||
|
||||
创建/编辑表单预选车辆会留下 draft 运输单,计划仍为 pending;
|
||||
若把非 cancelled 运输单都当成 rearrange,入库/出库会被误拦截。
|
||||
若把非 cancelled 运输单都当成 rearrange,会把首次正式安排误判为调整。
|
||||
existing_transport 保留入参以兼容调用方;草稿复用由后续分支处理。
|
||||
"""
|
||||
_ = existing_transport
|
||||
@@ -516,13 +538,6 @@ def arrange_transport(
|
||||
|
||||
is_rearrange = _is_rearrange(plan, existing_transport)
|
||||
|
||||
# 入库/出库:已安排后完全冻结,仅允许作废后新建计划再安排
|
||||
if is_rearrange and plan.plan_type in ("inbound", "outbound"):
|
||||
raise HTTPException(
|
||||
status_code=400,
|
||||
detail="已安排的入库/出库计划不可调整运输,请作废后新建计划再安排",
|
||||
)
|
||||
|
||||
if is_rearrange and existing_transport and existing_transport.vehicle_id:
|
||||
_assert_vehicle_carrier_eligible(
|
||||
db,
|
||||
@@ -646,6 +661,7 @@ def arrange_transport(
|
||||
)
|
||||
apply_resource_snapshot_json(plan=plan, transport=transport, snapshot=snapshot)
|
||||
plan.transport_status = "arranged"
|
||||
plan.follow_status = "arranged"
|
||||
plan.freight_amount = freight_amount or 0
|
||||
plan.update_by = user.id
|
||||
|
||||
@@ -660,6 +676,14 @@ def arrange_transport(
|
||||
|
||||
if plan.plan_type in ("inbound", "outbound"):
|
||||
try:
|
||||
if is_rearrange:
|
||||
# 调整运输:先作废旧出入库单(现场链接随之失效),再重建
|
||||
void_io_orders_for_plan(
|
||||
db,
|
||||
tenant_no=tenant_no,
|
||||
plan_id=plan.id,
|
||||
user_id=user.id,
|
||||
)
|
||||
io_result = create_io_order_for_transport(
|
||||
db,
|
||||
tenant_no=tenant_no,
|
||||
@@ -753,7 +777,7 @@ def get_transport(
|
||||
) -> TransportRead:
|
||||
tenant_no = get_tenant_no(db, user.to_tenant_user_dict())
|
||||
transport = _get_transport(db, tenant_no, id, user)
|
||||
return transport
|
||||
return _transport_to_read(db, transport)
|
||||
|
||||
|
||||
# =============================================================================
|
||||
|
||||
@@ -120,6 +120,15 @@ class TransportUpdate(BaseModel):
|
||||
model_config = {"populate_by_name": True}
|
||||
|
||||
|
||||
class TransportDriverProductFeedbackRead(BaseModel):
|
||||
plan_product_id: str = Field(alias="planProductId")
|
||||
product_name: str = Field(default="", alias="productName")
|
||||
actual_qty: Optional[Decimal] = Field(default=None, alias="actualQty")
|
||||
brand_summary: Optional[str] = Field(default=None, alias="brandSummary")
|
||||
brand_qtys: Optional[list[BrandQtyItem]] = Field(default=None, alias="brandQtys")
|
||||
model_config = {"populate_by_name": True}
|
||||
|
||||
|
||||
class TransportRead(TransportBase, PlanResourceSnapshotMixin):
|
||||
id: str
|
||||
transport_no: str = Field(alias="transportNo")
|
||||
@@ -128,6 +137,9 @@ class TransportRead(TransportBase, PlanResourceSnapshotMixin):
|
||||
feedback_qty: Optional[Decimal] = Field(default=None, alias="feedbackQty")
|
||||
feedback_images: Optional[str] = Field(default=None, alias="feedbackImages")
|
||||
feedback_remark: Optional[str] = Field(default=None, alias="feedbackRemark")
|
||||
driver_product_feedbacks: list[TransportDriverProductFeedbackRead] = Field(
|
||||
default_factory=list, alias="driverProductFeedbacks"
|
||||
)
|
||||
tenant_no: str = Field(alias="tenantNo")
|
||||
order_num: Optional[int] = Field(default=None, alias="orderNum")
|
||||
create_by: Optional[str] = Field(default=None, alias="createBy")
|
||||
|
||||
@@ -215,3 +215,81 @@ def persist_transport_product_feedback(
|
||||
)
|
||||
|
||||
transport.feedback_qty = total_qty
|
||||
|
||||
|
||||
def load_transport_driver_product_feedbacks(
|
||||
db: Session,
|
||||
*,
|
||||
tenant_no: str,
|
||||
transport_id: str,
|
||||
) -> list[dict]:
|
||||
"""管理端读运输单时附司机按产品回传及品牌摘要。"""
|
||||
from app.models.pl_models import (
|
||||
PlPlanProduct,
|
||||
PlTransportProductBrandQty,
|
||||
PlTransportProductFeedback,
|
||||
)
|
||||
|
||||
feedback_rows = (
|
||||
db.query(PlTransportProductFeedback)
|
||||
.filter(
|
||||
PlTransportProductFeedback.transport_id == transport_id,
|
||||
PlTransportProductFeedback.tenant_no == tenant_no,
|
||||
PlTransportProductFeedback.del_flag == 0,
|
||||
)
|
||||
.order_by(PlTransportProductFeedback.order_num.asc())
|
||||
.all()
|
||||
)
|
||||
if not feedback_rows:
|
||||
return []
|
||||
|
||||
plan_product_ids = [fb.plan_product_id for fb in feedback_rows if fb.plan_product_id]
|
||||
products_by_id: dict[str, PlPlanProduct] = {}
|
||||
if plan_product_ids:
|
||||
product_rows = (
|
||||
db.query(PlPlanProduct)
|
||||
.filter(
|
||||
PlPlanProduct.id.in_(plan_product_ids),
|
||||
PlPlanProduct.tenant_no == tenant_no,
|
||||
PlPlanProduct.del_flag == 0,
|
||||
)
|
||||
.all()
|
||||
)
|
||||
products_by_id = {row.id: row for row in product_rows}
|
||||
|
||||
brand_qtys_by_plan_product: dict[str, list[dict]] = {}
|
||||
feedback_ids = [fb.id for fb in feedback_rows]
|
||||
brand_qty_rows = (
|
||||
db.query(PlTransportProductBrandQty)
|
||||
.filter(
|
||||
PlTransportProductBrandQty.transport_id == transport_id,
|
||||
PlTransportProductBrandQty.tenant_no == tenant_no,
|
||||
PlTransportProductBrandQty.del_flag == 0,
|
||||
PlTransportProductBrandQty.feedback_id.in_(feedback_ids),
|
||||
)
|
||||
.order_by(PlTransportProductBrandQty.order_num.asc())
|
||||
.all()
|
||||
)
|
||||
for row in brand_qty_rows:
|
||||
brand_qtys_by_plan_product.setdefault(row.plan_product_id, []).append(
|
||||
{
|
||||
"brandId": row.brand_id or "",
|
||||
"brandName": row.brand_name,
|
||||
"qty": row.qty,
|
||||
}
|
||||
)
|
||||
|
||||
result: list[dict] = []
|
||||
for fb in feedback_rows:
|
||||
brand_qtys = brand_qtys_by_plan_product.get(fb.plan_product_id, [])
|
||||
pp = products_by_id.get(fb.plan_product_id or "")
|
||||
result.append(
|
||||
{
|
||||
"planProductId": fb.plan_product_id,
|
||||
"productName": (pp.product_name if pp else None) or "",
|
||||
"actualQty": fb.actual_qty,
|
||||
"brandQtys": brand_qtys or None,
|
||||
"brandSummary": format_brand_qty_summary(brand_qtys),
|
||||
}
|
||||
)
|
||||
return result
|
||||
@@ -570,6 +570,14 @@ export interface PlanArchiveBrandQtyItem {
|
||||
qty: number
|
||||
}
|
||||
|
||||
export interface TransportDriverProductFeedback {
|
||||
planProductId: string
|
||||
productName: string
|
||||
actualQty?: number
|
||||
brandSummary?: string
|
||||
brandQtys?: PlanArchiveBrandQtyItem[]
|
||||
}
|
||||
|
||||
export interface PlanArchiveProductItem {
|
||||
id: string
|
||||
actualQty: number
|
||||
@@ -702,6 +710,7 @@ export interface Transport {
|
||||
feedbackQty?: number
|
||||
feedbackImages?: string
|
||||
feedbackRemark?: string
|
||||
driverProductFeedbacks?: TransportDriverProductFeedback[]
|
||||
remark?: string
|
||||
createTime: string
|
||||
}
|
||||
@@ -787,6 +796,10 @@ export interface PlIoOrderItem {
|
||||
productName?: string
|
||||
brandSummary?: string
|
||||
brandName?: string
|
||||
brandMode?: string
|
||||
brandId?: string
|
||||
brandOptions?: Array<{ brandId: string; brandName?: string }>
|
||||
brandQtys?: PlanArchiveBrandQtyItem[]
|
||||
specification?: string
|
||||
unit?: string
|
||||
unitLabel?: string
|
||||
|
||||
@@ -125,7 +125,8 @@ import {
|
||||
planApi,
|
||||
type Plan,
|
||||
type PlanDriverFeedbackUpdateBody,
|
||||
type PlanProduct
|
||||
type PlanProduct,
|
||||
type TransportDriverProductFeedback
|
||||
} from '@/api/pl'
|
||||
import { useDictStore } from '@/store/modules/dict'
|
||||
import { pickBxData } from '@/utils/http/bx'
|
||||
@@ -152,6 +153,7 @@ const props = defineProps<{
|
||||
feedbackImages?: string | string[] | null
|
||||
feedbackTime?: string | null
|
||||
feedbackQty?: number | null
|
||||
driverProductFeedbacks?: TransportDriverProductFeedback[] | null
|
||||
}>()
|
||||
|
||||
const emit = defineEmits<{
|
||||
@@ -212,23 +214,40 @@ function resolveUnitLabel(unit?: string) {
|
||||
function mapBrandQtyRows(
|
||||
prod: PlanProduct,
|
||||
brandOptions: BrandOption[],
|
||||
seedActualQty: number
|
||||
seedActualQty: number,
|
||||
savedBrandQtys?: Array<{ brandId: string; brandName?: string; qty: number }> | null
|
||||
): BrandQtyRow[] {
|
||||
const savedPositive = (savedBrandQtys || [])
|
||||
.filter(r => Number(r.qty) > 0)
|
||||
.map(r => ({
|
||||
brandId: r.brandId,
|
||||
brandName: r.brandName || '',
|
||||
qty: Number(r.qty)
|
||||
}))
|
||||
if (prod.brandMode === 'required') {
|
||||
const brandId = prod.brandId || brandOptions[0]?.brandId || ''
|
||||
const brandName =
|
||||
prod.brandName ||
|
||||
brandOptions.find(o => o.brandId === brandId)?.brandName ||
|
||||
'指定品牌'
|
||||
return brandId ? [{ brandId, brandName, qty: seedActualQty }] : []
|
||||
if (!brandId) return []
|
||||
const saved = savedPositive.find(r => r.brandId === brandId)
|
||||
return [{ brandId, brandName, qty: saved ? saved.qty : seedActualQty }]
|
||||
}
|
||||
if (prod.brandMode === 'any') {
|
||||
const qtyMap = new Map(savedPositive.map(r => [r.brandId, r.qty]))
|
||||
const rows = brandOptions.map(opt => ({
|
||||
brandId: opt.brandId,
|
||||
brandName: opt.brandName,
|
||||
qty: 0
|
||||
qty: qtyMap.get(opt.brandId) ?? 0
|
||||
}))
|
||||
if (rows.length === 1) {
|
||||
// 保存过但不在 options 里的品牌也补回
|
||||
for (const saved of savedPositive) {
|
||||
if (!rows.some(r => r.brandId === saved.brandId)) {
|
||||
rows.push(saved)
|
||||
}
|
||||
}
|
||||
if (!savedPositive.length && rows.length === 1) {
|
||||
rows[0].qty = seedActualQty
|
||||
}
|
||||
return rows
|
||||
@@ -255,8 +274,10 @@ async function loadBrandOptions(productId: string): Promise<BrandOption[]> {
|
||||
function resolveSeedActualQty(
|
||||
prod: PlanProduct,
|
||||
transportFeedbackQty: number | null | undefined,
|
||||
productCount: number
|
||||
productCount: number,
|
||||
savedFeedback?: TransportDriverProductFeedback | null
|
||||
) {
|
||||
if (savedFeedback?.actualQty != null) return Number(savedFeedback.actualQty)
|
||||
if (prod.actualQty != null) return Number(prod.actualQty)
|
||||
if (productCount === 1 && transportFeedbackQty != null) {
|
||||
return Number(transportFeedbackQty)
|
||||
@@ -266,6 +287,9 @@ function resolveSeedActualQty(
|
||||
|
||||
async function buildProductRows(plan: Plan, transportFeedbackQty?: number | null) {
|
||||
const products = Array.isArray(plan.products) ? plan.products : []
|
||||
const savedByPlanProductId = new Map(
|
||||
(props.driverProductFeedbacks || []).map(item => [item.planProductId, item])
|
||||
)
|
||||
const brandOptionMap = new Map<string, BrandOption[]>()
|
||||
|
||||
await Promise.all(
|
||||
@@ -283,8 +307,19 @@ async function buildProductRows(plan: Plan, transportFeedbackQty?: number | null
|
||||
: prod.brandId
|
||||
? [{ brandId: prod.brandId, brandName: prod.brandName || '指定品牌' }]
|
||||
: []
|
||||
const seedActualQty = resolveSeedActualQty(prod, transportFeedbackQty, products.length)
|
||||
const brandQtyRows = mapBrandQtyRows(prod, brandOptions, seedActualQty)
|
||||
const savedFeedback = savedByPlanProductId.get(prod.id) || null
|
||||
const seedActualQty = resolveSeedActualQty(
|
||||
prod,
|
||||
transportFeedbackQty,
|
||||
products.length,
|
||||
savedFeedback
|
||||
)
|
||||
const brandQtyRows = mapBrandQtyRows(
|
||||
prod,
|
||||
brandOptions,
|
||||
seedActualQty,
|
||||
savedFeedback?.brandQtys
|
||||
)
|
||||
const actualQty = prod.brandMode
|
||||
? Number(brandQtySum(brandQtyRows).toFixed(3))
|
||||
: seedActualQty
|
||||
|
||||
@@ -119,58 +119,81 @@
|
||||
<section class="pl-plan-form-section pl-plan-form-section--plain">
|
||||
<div class="pl-plan-form-section-head">
|
||||
<h3 class="pl-plan-form-section-title">司机回传信息</h3>
|
||||
<el-button
|
||||
v-if="feedbackEditable"
|
||||
class="btn-op-item"
|
||||
:disabled="!canEditDriverFeedback"
|
||||
@click="openDriverFeedbackDialog"
|
||||
>
|
||||
<el-icon><Edit /></el-icon>
|
||||
{{ hasDriverFeedback ? '编辑' : '补充' }}
|
||||
</el-button>
|
||||
<div v-if="feedbackEditable" class="pl-plan-form-section-actions">
|
||||
<el-button
|
||||
type="primary"
|
||||
class="btn-op-item"
|
||||
:disabled="!canEditDriverFeedback"
|
||||
@click="openDriverFeedbackDialog"
|
||||
>
|
||||
<el-icon><Edit /></el-icon>
|
||||
{{ hasDriverFeedback ? '编辑' : '补充' }}
|
||||
</el-button>
|
||||
<el-button
|
||||
v-if="arrangeDriverUrl"
|
||||
class="btn-op-item"
|
||||
@click="copyArrangeDriverUrl"
|
||||
>
|
||||
<el-icon><CopyDocument /></el-icon>
|
||||
复制司机链接
|
||||
</el-button>
|
||||
</div>
|
||||
</div>
|
||||
<p v-if="!hasDriverFeedback" class="pl-plan-form-empty-hint">暂无司机回传</p>
|
||||
<div v-else class="view-subtable-wrap">
|
||||
<el-table :data="driverFeedbackTableRows" class="view-subtable list-table" stripe>
|
||||
<el-table-column
|
||||
type="index"
|
||||
label="序号"
|
||||
min-width="68"
|
||||
align="center"
|
||||
header-align="center"
|
||||
/>
|
||||
<el-table-column
|
||||
prop="feedbackTime"
|
||||
label="回传时间"
|
||||
min-width="160"
|
||||
align="center"
|
||||
/>
|
||||
<el-table-column
|
||||
prop="feedbackQty"
|
||||
label="回传数量"
|
||||
min-width="100"
|
||||
align="center"
|
||||
>
|
||||
<template #default="{ row }">
|
||||
{{ row.feedbackQty ?? '—' }}
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column
|
||||
prop="feedbackRemark"
|
||||
label="回传备注"
|
||||
min-width="180"
|
||||
show-overflow-tooltip
|
||||
/>
|
||||
<el-table-column label="回传附件" min-width="140" align="center" header-align="center">
|
||||
<template #default="{ row }">
|
||||
<div v-if="row.feedbackImages" class="pl-plan-feedback-table__attachment">
|
||||
<AttachmentUploadField :model-value="row.feedbackImages" disabled compact />
|
||||
</div>
|
||||
<span v-else class="pl-plan-feedback-table__empty-cell">—</span>
|
||||
</template>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
</div>
|
||||
<template v-else>
|
||||
<div class="view-subtable-wrap">
|
||||
<el-table :data="driverFeedbackTableRows" class="view-subtable list-table" stripe>
|
||||
<el-table-column
|
||||
type="index"
|
||||
label="序号"
|
||||
min-width="68"
|
||||
align="center"
|
||||
header-align="center"
|
||||
/>
|
||||
<el-table-column
|
||||
prop="productName"
|
||||
label="产品"
|
||||
min-width="140"
|
||||
show-overflow-tooltip
|
||||
/>
|
||||
<el-table-column
|
||||
prop="actualQty"
|
||||
label="回传数量"
|
||||
min-width="100"
|
||||
align="right"
|
||||
>
|
||||
<template #default="{ row }">
|
||||
{{ row.actualQty ?? '—' }}
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="品牌数量" min-width="180" show-overflow-tooltip>
|
||||
<template #default="{ row }">
|
||||
{{ row.brandSummary || '—' }}
|
||||
</template>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
</div>
|
||||
<div class="pl-plan-io-site-meta">
|
||||
<div class="pl-plan-io-site-meta__item">
|
||||
<p class="pl-plan-form-empty-hint" style="margin-bottom: 6px">回传时间</p>
|
||||
<p class="pl-plan-view-remark">{{ displayFeedbackTime }}</p>
|
||||
</div>
|
||||
<div class="pl-plan-io-site-meta__item">
|
||||
<p class="pl-plan-form-empty-hint" style="margin-bottom: 6px">回传备注</p>
|
||||
<p class="pl-plan-view-remark">{{ transport?.feedbackRemark || '—' }}</p>
|
||||
</div>
|
||||
<div class="pl-plan-io-site-meta__item">
|
||||
<p class="pl-plan-form-empty-hint" style="margin-bottom: 6px">回传附件</p>
|
||||
<AttachmentUploadField
|
||||
v-if="feedbackImageCsv"
|
||||
:model-value="feedbackImageCsv"
|
||||
disabled
|
||||
compact
|
||||
/>
|
||||
<span v-else class="pl-plan-feedback-table__empty-cell">—</span>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
</section>
|
||||
|
||||
<section class="pl-plan-form-section pl-plan-form-section--plain">
|
||||
@@ -178,14 +201,25 @@
|
||||
<h3 class="pl-plan-form-section-title">
|
||||
{{ ioOrder ? (ioOrder.kind === 'inbound' ? '入库单回传' : '出库单回传') : '现场回传信息' }}
|
||||
</h3>
|
||||
<el-button
|
||||
v-if="ioOrder?.siteUrl"
|
||||
class="btn-op-item"
|
||||
@click="copyArrangeSiteUrl(ioOrder.siteUrl)"
|
||||
>
|
||||
<el-icon><CopyDocument /></el-icon>
|
||||
复制现场链接
|
||||
</el-button>
|
||||
<div v-if="ioOrder" class="pl-plan-form-section-actions">
|
||||
<el-button
|
||||
v-if="feedbackEditable && ioOrder.status !== 'voided'"
|
||||
type="primary"
|
||||
class="btn-op-item"
|
||||
@click="openIoOrderEditDialog"
|
||||
>
|
||||
<el-icon><Edit /></el-icon>
|
||||
{{ ioOrderHasFeedback ? '编辑' : '补充' }}
|
||||
</el-button>
|
||||
<el-button
|
||||
v-if="ioOrder.siteUrl"
|
||||
class="btn-op-item"
|
||||
@click="copyArrangeSiteUrl(ioOrder.siteUrl)"
|
||||
>
|
||||
<el-icon><CopyDocument /></el-icon>
|
||||
复制现场链接
|
||||
</el-button>
|
||||
</div>
|
||||
</div>
|
||||
<!-- 新链路:入库/出库单权威展示 -->
|
||||
<template v-if="ioOrder">
|
||||
@@ -201,6 +235,11 @@
|
||||
</el-table-column>
|
||||
<el-table-column prop="planQty" label="计划数量" min-width="100" align="right" />
|
||||
<el-table-column prop="actualQty" label="实际数量" min-width="100" align="right" />
|
||||
<el-table-column label="品牌数量" min-width="180" show-overflow-tooltip>
|
||||
<template #default="{ row }">
|
||||
{{ resolveSiteBrandSummary(row) }}
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column prop="packageSpec" label="包装规格" min-width="110" show-overflow-tooltip />
|
||||
<el-table-column prop="remark" label="备注" min-width="120" show-overflow-tooltip />
|
||||
</el-table>
|
||||
@@ -221,12 +260,6 @@
|
||||
<span v-else class="pl-plan-feedback-table__empty-cell">—</span>
|
||||
</div>
|
||||
</div>
|
||||
<div v-if="feedbackEditable && ioOrder.status !== 'voided'" style="margin-top: 12px">
|
||||
<el-button @click="openIoOrderEditDialog">
|
||||
<el-icon><Edit /></el-icon>
|
||||
{{ ioOrderHasFeedback ? '编辑' : '补充' }}
|
||||
</el-button>
|
||||
</div>
|
||||
</template>
|
||||
<!-- 旧链路:按产品现场 link -->
|
||||
<template v-else>
|
||||
@@ -474,6 +507,7 @@
|
||||
:feedback-images="transport?.feedbackImages"
|
||||
:feedback-time="transport?.feedbackTime"
|
||||
:feedback-qty="transport?.feedbackQty"
|
||||
:driver-product-feedbacks="transport?.driverProductFeedbacks"
|
||||
@success="handleFeedbackSaved"
|
||||
/>
|
||||
<PlPlanSiteFeedbackDialog
|
||||
@@ -499,22 +533,49 @@
|
||||
>
|
||||
<el-form v-if="ioOrderEditForm" label-position="top">
|
||||
<el-form-item label="产品实际数量">
|
||||
<el-table :data="ioOrderEditForm.items || []" size="small" border>
|
||||
<el-table-column prop="productNo" label="产品编码" min-width="110" show-overflow-tooltip />
|
||||
<el-table-column prop="productName" label="产品名称" min-width="120" show-overflow-tooltip />
|
||||
<el-table-column prop="specification" label="型号/规格" min-width="100" show-overflow-tooltip />
|
||||
<el-table-column label="单位" min-width="72" align="center">
|
||||
<template #default="{ row }">{{ row.unitLabel || row.unit || '—' }}</template>
|
||||
</el-table-column>
|
||||
<el-table-column prop="planQty" label="计划数量" min-width="100" align="right" />
|
||||
<el-table-column label="实际数量" min-width="120">
|
||||
<template #default="{ row }">
|
||||
<el-input-number v-model="row.actualQty" :min="0" :precision="3" :controls="false" />
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column prop="packageSpec" label="包装规格" min-width="110" show-overflow-tooltip />
|
||||
<el-table-column prop="remark" label="备注" min-width="120" show-overflow-tooltip />
|
||||
</el-table>
|
||||
<div
|
||||
v-for="(row, idx) in ioOrderEditForm.items || []"
|
||||
:key="row.id"
|
||||
class="pl-io-order-edit-item"
|
||||
>
|
||||
<div class="pl-io-order-edit-item__head">
|
||||
<span class="pl-io-order-edit-item__name">{{ row.productName || '产品' }}</span>
|
||||
<span class="pl-io-order-edit-item__badge">
|
||||
产品 {{ idx + 1 }}/{{ ioOrderEditForm.items?.length || 0 }}
|
||||
</span>
|
||||
</div>
|
||||
<el-table :data="[row]" size="small" border class="pl-io-order-edit-item__table">
|
||||
<el-table-column prop="productNo" label="产品编码" min-width="110" show-overflow-tooltip />
|
||||
<el-table-column prop="specification" label="型号/规格" min-width="100" show-overflow-tooltip />
|
||||
<el-table-column label="单位" min-width="72" align="center">
|
||||
<template #default="{ row: itemRow }">{{ itemRow.unitLabel || itemRow.unit || '—' }}</template>
|
||||
</el-table-column>
|
||||
<el-table-column prop="planQty" label="计划数量" min-width="100" align="right" />
|
||||
<el-table-column label="实际数量" min-width="120">
|
||||
<template #default="{ row: itemRow }">
|
||||
<el-input-number
|
||||
v-model="itemRow.actualQty"
|
||||
:min="0"
|
||||
:precision="3"
|
||||
:controls="false"
|
||||
:disabled="Boolean(itemRow.brandMode)"
|
||||
/>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column prop="packageSpec" label="包装规格" min-width="110" show-overflow-tooltip />
|
||||
</el-table>
|
||||
<BrandQtyChipsField
|
||||
v-if="row.brandMode"
|
||||
v-model="row.brandQtyRows"
|
||||
:brand-mode="ioBrandModeForField(row)"
|
||||
:required-brand-id="row.brandId"
|
||||
:brand-options="row.brandOptions || []"
|
||||
:unit="row.unitLabel || row.unit || '吨'"
|
||||
variant="admin"
|
||||
:actual-qty="Number(row.actualQty ?? 0)"
|
||||
@update:actual-qty="(val) => syncIoRowActualQty(row, val)"
|
||||
/>
|
||||
</div>
|
||||
</el-form-item>
|
||||
<el-form-item label="现场备注">
|
||||
<el-input v-model="ioOrderEditForm.siteFeedbackRemark" type="textarea" :rows="3" maxlength="500" />
|
||||
@@ -539,6 +600,9 @@
|
||||
<script setup lang="ts">
|
||||
import { CopyDocument, Edit, View } from '@element-plus/icons-vue'
|
||||
import AttachmentUploadField from '@/components/business/attachment-upload-field/index.vue'
|
||||
import BrandQtyChipsField, {
|
||||
type BrandQtyRow
|
||||
} from '@/components/business/brand-qty-chips-field/index.vue'
|
||||
import PlPlanDriverFeedbackDialog from '@/components/business/pl-plan-driver-feedback-dialog/index.vue'
|
||||
import PlPlanFormProductTable from '@/components/business/pl-plan-form-dialog/PlPlanFormProductTable.vue'
|
||||
import PlPlanHazardCertViewTable from '@/components/business/pl-plan-hazard-cert-view-table/index.vue'
|
||||
@@ -571,15 +635,17 @@
|
||||
} from '@/utils/db-site-summary'
|
||||
import {
|
||||
formatPlanProductListText,
|
||||
formatBrandQtySummary,
|
||||
getPlFreightTypeLabel,
|
||||
getPlHasInvoiceLabelFromSettlement,
|
||||
getPlPlanCompanyLabel,
|
||||
getPlPlanTypeLabel,
|
||||
getPlYesNoLabel,
|
||||
parsePlFeedbackImages
|
||||
parsePlFeedbackImages,
|
||||
resolveSiteBrandSummary
|
||||
} from '@/utils/pl-display'
|
||||
import { formatMoneyDisplay } from '@/utils/money-format'
|
||||
import type { Transport } from '@/api/pl'
|
||||
import type { Transport, TransportDriverProductFeedback } from '@/api/pl'
|
||||
|
||||
const ContractDetailDialog = defineAsyncComponent(
|
||||
() => import('@/views/crm/contract/components/ContractDetailDialog.vue')
|
||||
@@ -676,11 +742,64 @@
|
||||
]
|
||||
})
|
||||
|
||||
type IoOrderEditItem = PlIoOrder['items'][number] & {
|
||||
brandQtyRows?: BrandQtyRow[]
|
||||
}
|
||||
|
||||
function ioBrandModeForField(row: { brandMode?: string | null }): 'any' | 'required' | null {
|
||||
if (row.brandMode === 'any' || row.brandMode === 'required') return row.brandMode
|
||||
return null
|
||||
}
|
||||
|
||||
function syncIoRowActualQty(row: IoOrderEditItem, val: number) {
|
||||
row.actualQty = Number(val)
|
||||
}
|
||||
|
||||
function mapIoItemBrandQtyRows(it: PlIoOrder['items'][number]): BrandQtyRow[] {
|
||||
const saved = (it.brandQtys || [])
|
||||
.filter(r => Number(r.qty) > 0)
|
||||
.map(r => ({
|
||||
brandId: r.brandId,
|
||||
brandName: r.brandName || '',
|
||||
qty: Number(r.qty)
|
||||
}))
|
||||
if (saved.length) return saved
|
||||
if (it.brandMode === 'required' && it.brandId) {
|
||||
return [
|
||||
{
|
||||
brandId: it.brandId,
|
||||
brandName: it.brandName || '指定品牌',
|
||||
qty: Number(it.actualQty ?? 0)
|
||||
}
|
||||
]
|
||||
}
|
||||
if (it.brandMode === 'any') {
|
||||
return (it.brandOptions || []).map(opt => ({
|
||||
brandId: opt.brandId,
|
||||
brandName: opt.brandName || '',
|
||||
qty: 0
|
||||
}))
|
||||
}
|
||||
return []
|
||||
}
|
||||
|
||||
function openIoOrderEditDialog() {
|
||||
if (!ioOrder.value) return
|
||||
ioOrderEditForm.value = {
|
||||
...ioOrder.value,
|
||||
items: (ioOrder.value.items || []).map(it => ({ ...it }))
|
||||
items: (ioOrder.value.items || []).map(it => {
|
||||
const brandQtyRows = mapIoItemBrandQtyRows(it)
|
||||
const actualQty = it.brandMode
|
||||
? Number(
|
||||
brandQtyRows.reduce((sum, r) => sum + Number(r.qty || 0), 0).toFixed(3)
|
||||
)
|
||||
: it.actualQty
|
||||
return {
|
||||
...it,
|
||||
brandQtyRows,
|
||||
actualQty
|
||||
}
|
||||
})
|
||||
}
|
||||
ioOrderEditImagesCsv.value = ioOrderImageCsv.value
|
||||
ioOrderEditVisible.value = true
|
||||
@@ -688,6 +807,21 @@
|
||||
|
||||
async function saveIoOrderEdit() {
|
||||
if (!ioOrderEditForm.value) return
|
||||
const items = (ioOrderEditForm.value.items || []) as IoOrderEditItem[]
|
||||
for (const it of items) {
|
||||
if (!it.brandMode) continue
|
||||
const rows = it.brandQtyRows || []
|
||||
const positive = rows.filter(r => Number(r.qty) > 0)
|
||||
if (!positive.length) {
|
||||
ElMessage.warning(`「${it.productName || '产品'}」请至少填写一个品牌数量`)
|
||||
return
|
||||
}
|
||||
const total = Number(positive.reduce((s, r) => s + Number(r.qty || 0), 0).toFixed(3))
|
||||
if (Math.abs(total - Number(it.actualQty ?? 0)) >= 0.0005) {
|
||||
ElMessage.warning(`「${it.productName || '产品'}」品牌数量合计须等于实际数量`)
|
||||
return
|
||||
}
|
||||
}
|
||||
const api = ioOrderEditForm.value.kind === 'inbound' ? inboundOrderApi : outboundOrderApi
|
||||
ioOrderSaving.value = true
|
||||
try {
|
||||
@@ -697,9 +831,18 @@
|
||||
await api.patch(ioOrderEditForm.value.id, {
|
||||
siteFeedbackRemark: ioOrderEditForm.value.siteFeedbackRemark,
|
||||
siteFeedbackImages: images,
|
||||
items: (ioOrderEditForm.value.items || []).map(it => ({
|
||||
items: items.map(it => ({
|
||||
id: it.id,
|
||||
actualQty: it.actualQty
|
||||
actualQty: Number(it.actualQty ?? 0),
|
||||
brandQtys: it.brandMode
|
||||
? (it.brandQtyRows || [])
|
||||
.filter(r => Number(r.qty) > 0)
|
||||
.map(r => ({
|
||||
brandId: r.brandId,
|
||||
brandName: r.brandName,
|
||||
qty: Number(r.qty)
|
||||
}))
|
||||
: undefined
|
||||
}))
|
||||
})
|
||||
ElMessage.success('保存成功')
|
||||
@@ -721,7 +864,8 @@
|
||||
transport.value?.feedbackTime ||
|
||||
transport.value?.feedbackRemark ||
|
||||
feedbackImageList.value.length ||
|
||||
transport.value?.feedbackQty != null
|
||||
transport.value?.feedbackQty != null ||
|
||||
(transport.value?.driverProductFeedbacks || []).length
|
||||
)
|
||||
)
|
||||
|
||||
@@ -731,13 +875,21 @@
|
||||
}
|
||||
|
||||
const driverFeedbackTableRows = computed(() => {
|
||||
const rows = transport.value?.driverProductFeedbacks || []
|
||||
if (rows.length) {
|
||||
return rows.map((row: TransportDriverProductFeedback) => ({
|
||||
productName: row.productName || '—',
|
||||
actualQty: row.actualQty,
|
||||
brandSummary: row.brandSummary || formatBrandQtySummary(row.brandQtys) || '—'
|
||||
}))
|
||||
}
|
||||
if (!hasDriverFeedback.value) return []
|
||||
// 兼容旧数据:仅有运输单总量、无按产品明细
|
||||
return [
|
||||
{
|
||||
feedbackTime: displayFeedbackTime.value,
|
||||
feedbackQty: transport.value?.feedbackQty,
|
||||
feedbackRemark: transport.value?.feedbackRemark || '—',
|
||||
feedbackImages: feedbackImageCsv.value
|
||||
productName: '(合计)',
|
||||
actualQty: transport.value?.feedbackQty,
|
||||
brandSummary: '—'
|
||||
}
|
||||
]
|
||||
})
|
||||
|
||||
@@ -94,11 +94,12 @@ export function getPlanProductQuantity(product: {
|
||||
inboundEstimateQty?: number | string | null
|
||||
outboundEstimateQty?: number | string | null
|
||||
}) {
|
||||
const qty =
|
||||
product.actualQty ??
|
||||
product.quantity ??
|
||||
product.inboundEstimateQty ??
|
||||
product.outboundEstimateQty
|
||||
const actual = product.actualQty
|
||||
// 实际数量为空或为 0 时,展示合同/计划数量
|
||||
if (actual !== undefined && actual !== null && actual !== '' && Number(actual) !== 0) {
|
||||
return String(actual)
|
||||
}
|
||||
const qty = product.quantity ?? product.inboundEstimateQty ?? product.outboundEstimateQty
|
||||
if (qty === undefined || qty === null || qty === '') return '—'
|
||||
return String(qty)
|
||||
}
|
||||
@@ -146,6 +147,67 @@ export function formatPlanProductListText(
|
||||
return `${name}${specPart},${qtyUnit}`
|
||||
}
|
||||
|
||||
/** 入库单/出库单列表产品一行:名称 + 品牌/型号规格/单位/包装规格/送货方式 */
|
||||
export function formatIoOrderProductListText(item: {
|
||||
productName?: string | null
|
||||
brandSummary?: string | null
|
||||
brandName?: string | null
|
||||
specification?: string | null
|
||||
unit?: string | null
|
||||
unitLabel?: string | null
|
||||
packageSpec?: string | null
|
||||
deliveryMethod?: string | null
|
||||
}) {
|
||||
const name = (item.productName || '').trim() || '—'
|
||||
const bits: string[] = []
|
||||
const brand = (item.brandSummary || item.brandName || '').trim()
|
||||
if (brand) bits.push(`品牌 ${brand}`)
|
||||
const spec = (item.specification || '').trim()
|
||||
if (spec) bits.push(`型号/规格 ${spec}`)
|
||||
const unit = (item.unitLabel || item.unit || '').trim()
|
||||
if (unit) bits.push(`单位 ${unit}`)
|
||||
const packageSpec = (item.packageSpec || '').trim()
|
||||
if (packageSpec) bits.push(`包装规格 ${packageSpec}`)
|
||||
const delivery = (item.deliveryMethod || '').trim()
|
||||
if (delivery) {
|
||||
const deliveryLabels: Record<string, string> = {
|
||||
self_pick: '山峡自提',
|
||||
one_ticket: '一票制',
|
||||
customer_pick: '客户自提'
|
||||
}
|
||||
bits.push(`送货方式 ${deliveryLabels[delivery] || delivery}`)
|
||||
}
|
||||
return bits.length ? `${name},${bits.join(',')}` : name
|
||||
}
|
||||
|
||||
/** 品牌数量摘要,如 `君正 16 / 红四方 12` */
|
||||
export function formatBrandQtySummary(
|
||||
rows?: Array<{ brandName?: string | null; qty?: number | string | null }> | null
|
||||
): string {
|
||||
if (!rows?.length) return ''
|
||||
const parts = rows
|
||||
.map(row => {
|
||||
const qty = Number(row.qty ?? 0)
|
||||
if (!Number.isFinite(qty) || qty <= 0) return ''
|
||||
const name = (row.brandName || '').trim() || '未命名品牌'
|
||||
return `${name} ${qty}`
|
||||
})
|
||||
.filter(Boolean)
|
||||
return parts.join(' / ')
|
||||
}
|
||||
|
||||
/** 现场入出库明细品牌摘要(优先 brandQtys,其次 brandSummary) */
|
||||
export function resolveSiteBrandSummary(item: {
|
||||
brandQtys?: Array<{ brandName?: string | null; qty?: number | string | null }> | null
|
||||
brandSummary?: string | null
|
||||
brandName?: string | null
|
||||
}) {
|
||||
const fromQtys = formatBrandQtySummary(item.brandQtys)
|
||||
if (fromQtys) return fromQtys
|
||||
const summary = (item.brandSummary || item.brandName || '').trim()
|
||||
return summary || '—'
|
||||
}
|
||||
|
||||
/** 司机公开页产品一行展示(含运输计划产品备注) */
|
||||
export function formatPublicTransportProductLine(product: {
|
||||
productName?: string
|
||||
@@ -223,22 +285,38 @@ export function plPlanTypeFilterToTab(planType?: string): PlPlanTypeTab {
|
||||
return 'all'
|
||||
}
|
||||
|
||||
/** 运输计划跟进状态选项(筛选) */
|
||||
export const PL_PLAN_FOLLOW_STATUS_OPTIONS = [
|
||||
{ label: '等通知', value: 'wait_notice' },
|
||||
{ label: '待安排', value: 'pending_arrange' },
|
||||
{ label: '已安排', value: 'arranged' },
|
||||
{ label: '已完成', value: 'completed' },
|
||||
{ label: '已取消', value: 'cancelled' }
|
||||
] as const
|
||||
|
||||
export function getPlPlanFollowStatusTagType(status?: string) {
|
||||
const map: Record<string, string> = {
|
||||
draft: 'info',
|
||||
processing: 'warning',
|
||||
wait_notice: 'warning',
|
||||
pending_arrange: 'danger',
|
||||
arranged: 'success',
|
||||
completed: 'success',
|
||||
cancelled: 'danger'
|
||||
cancelled: 'info',
|
||||
// 旧值兼容(迁移前)
|
||||
draft: 'danger',
|
||||
processing: 'warning'
|
||||
}
|
||||
return map[status || ''] || 'info'
|
||||
}
|
||||
|
||||
export function getPlPlanFollowStatusLabel(status?: string) {
|
||||
const map: Record<string, string> = {
|
||||
draft: '草稿',
|
||||
processing: '进行中',
|
||||
wait_notice: '等通知',
|
||||
pending_arrange: '待安排',
|
||||
arranged: '已安排',
|
||||
completed: '已完成',
|
||||
cancelled: '已作废'
|
||||
cancelled: '已取消',
|
||||
draft: '待安排',
|
||||
processing: '进行中'
|
||||
}
|
||||
return status ? map[status] || status : '—'
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user