Files
shanxia2.0/web-admin/src/views/m/pl/plan/PlanStopReadCard.vue
T
wuzilong 9f855423d8 fix(pl): 客户品类规则预占不再依赖合同绑证 scope。
新规则自动选证后账本仍按合同绑证判定适用,导致预占报人工分配不适用;改为客户品类路径跳过 scope,明细合同绑证字段可空,并统一关联购买证文案。
2026-11-15 08:01:14 +08:00

444 lines
12 KiB
Vue

<template>
<article class="stop-read">
<header class="stop-read__head">
<div class="stop-read__heading">
<span class="stop-read__sequence">{{ sequence || 1 }}</span>
<h4>{{ title }}段次</h4>
</div>
<div class="stop-read__customer">{{ stop.customerName || '—' }}</div>
</header>
<section class="stop-read__section">
<h4 class="stop-read__section-title">基本信息</h4>
<div class="fields">
<div
><small>{{ title }}时间</small
><span>{{
formatMpPlanYmd(stopType === 'load' ? stop.loadTime : stop.deliveryTime)
}}</span></div
>
<div
><small>联系方式</small><span>{{ stop.contact || '—' }}</span></div
>
<div
><small>是否同市</small
><span>{{ Number(stop.sameCity) === 1 ? '是(同市只需购买证)' : '否' }}</span></div
>
<div class="wide"
><small>{{ title }}地址</small><span>{{ displayAddress || '—' }}</span></div
>
<div class="wide"
><small>注意事项</small><span>{{ stop.notes || '—' }}</span></div
>
<div class="wide"
><small>备注</small><span>{{ stop.remark || '—' }}</span></div
>
<div class="wide"
><small>合同</small>
<button
v-for="c in stop.contracts || []"
:key="c.contractId"
class="contract-link"
@click="viewContract(c)"
>{{ c.contractNo || c.contractId }}</button
>
<span v-if="!stop.contracts?.length">—</span>
</div>
</div>
</section>
<section class="stop-read__section">
<h4 class="stop-read__section-title"
>产品明细<span>{{ stop.products?.length || 0 }} 项</span></h4
>
<article
v-for="(p, i) in stop.products || []"
:key="p.id || `${p.planProductId}-${i}`"
class="product"
>
<h5 class="product-title">
<van-tag class="product-index" color="#0a9f6d">{{ i + 1 }}</van-tag>
<span>{{ productDisplayName(p) }}</span>
<span v-if="hazardFlags(p).isToxic || hazardFlags(p).isExplosive" class="product-hazards">
<MpProductHazardTag v-if="hazardFlags(p).isToxic" kind="toxic" />
<MpProductHazardTag v-if="hazardFlags(p).isExplosive" kind="explosive" />
</span>
</h5>
<div class="fields fields--compact">
<div
><small>计划数量</small
><span>{{ p.planQty ?? '—' }}{{ resolveMpProductUnitLabel(p.unit) }}</span></div
>
<div
><small>实际数量</small><span>{{ actualQuantity(p, stopType) }}</span></div
>
<div
><small>别名</small><span>{{ metadata(p).aliasName || '—' }}</span></div
>
<div
><small>品牌</small
><span>{{
formatBrandConstraintLabel(metadata(p).brandMode, metadata(p).brandName) || '—'
}}</span></div
>
<div
><small>规格型号</small><span>{{ p.model || '—' }}</span></div
>
<div
><small>包装</small><span>{{ resolveMpPackageSpecLabel(p.packageSpec) }}</span></div
>
<div
><small>送货方式</small
><span>{{ resolveMpDeliveryMethodLabel(p.deliveryMethod) }}</span></div
>
<div
><small>产品合同</small
><button
v-if="p.contractId"
class="contract-link"
@click="viewContract({ contractId: p.contractId, contractNo: p.contractNo })"
>{{ p.contractNo || p.contractId }}</button
><span v-else>—</span></div
>
<div class="wide"
><small>产品备注</small><span>{{ p.remark || '—' }}</span></div
>
</div>
</article>
<p v-if="!stop.products?.length" class="stop-read__empty">暂无产品明细</p>
</section>
<section class="stop-read__section">
<h4 class="stop-read__section-title">回传记录</h4>
<PlanStopFeedbackCard
:feedbacks="stopFeedbacks(transport, stop, stopType)"
:dibang-rows="matchedDibang"
:incomplete="incomplete"
/>
</section>
<van-popup
:show="!!selectedContract"
position="bottom"
teleport="body"
round
class="mp-customer-vant-popup plan-contract-sheet"
@update:show="!$event && closeContract()"
>
<div class="plan-contract-sheet__panel">
<van-nav-bar title="合同详情" left-text="关闭" @click-left="closeContract()" />
<div class="plan-contract-sheet__body">
<MobileContractDetail
v-if="selectedContract"
:key="String(selectedContract.contractId || '')"
embedded
:record-id="String(selectedContract.contractId || '')"
:hide-product-price="hideProductPrice"
/>
</div>
</div>
</van-popup>
</article>
</template>
<script setup lang="ts">
import MpProductHazardTag from '@/components/mp/MpProductHazardTag.vue'
import type {
PlanLoad,
PlanDelivery,
PlanProduct,
PlanStopProduct,
Transport,
PlanContractLink
} from '@/api/pl'
import {
actualQuantity,
matchStopLinks,
stopFeedbacks,
stopProductMetadata
} from './mobileDetailDisplay'
import {
formatMpPlanYmd,
resolveMpProductUnitLabel,
resolveMpPackageSpecLabel,
resolveMpDeliveryMethodLabel
} from '@/utils/mp-pl-plan-display'
import { formatBrandConstraintLabel } from '@/utils/crm-product-brand'
import { resolveProductHazardFlags } from '@/composables/usePlToxicProductCertCheck'
import PlanStopFeedbackCard from './PlanStopFeedbackCard.vue'
import MobileContractDetail from '@/views/m/crm/contract/detail.vue'
import { useContractDetailDialog } from '@/composables/useContractDetailDialog'
const { hideProductPrice, loadProductPricePermission } = useContractDetailDialog({
gateProductPriceByPerm: true
})
const props = defineProps<{
stop: PlanLoad & PlanDelivery
stopType: 'load' | 'delivery'
sequence?: number
products: PlanProduct[]
transport: Transport | null
dibangRows: any[]
incomplete?: boolean
/** 查看态地址(含计划级回退),缺省用 stop.address */
address?: string
}>()
const selectedContract = ref<PlanContractLink | null>(null)
let contractGeneration = 0
function closeContract() {
contractGeneration++
selectedContract.value = null
}
onBeforeUnmount(() => {
closeContract()
})
async function viewContract(contract: PlanContractLink) {
const generation = ++contractGeneration
await loadProductPricePermission()
if (generation === contractGeneration) selectedContract.value = contract
}
const title = computed(() => (props.stopType === 'load' ? '装货' : '送货'))
const displayAddress = computed(() => (props.address ?? props.stop.address ?? '').trim() || '')
const matchedDibang = computed(() => {
const links = matchStopLinks(
props.dibangRows.map((row) => row.link),
props.stop,
props.stopType
)
return props.dibangRows.filter((row) => links.includes(row.link))
})
function linkedPlanProduct(p: PlanStopProduct) {
return props.products.find((product) => product.id === p.planProductId)
}
function metadata(p: PlanStopProduct) {
return stopProductMetadata(p, props.products)
}
function productDisplayName(p: PlanStopProduct) {
const linked = linkedPlanProduct(p)
return linked?.standardProductName || p.productName || linked?.productName || '—'
}
function hazardFlags(p: PlanStopProduct) {
return resolveProductHazardFlags(linkedPlanProduct(p) || p)
}
</script>
<style scoped>
.stop-read {
min-width: 0;
margin-top: 8px;
overflow: hidden;
font-size: 14px;
background: #f7faf8;
border: 1px solid #dcebe4;
border-radius: 12px;
}
.stop-read__head {
padding: 10px 12px;
color: #087f57;
background: #e9f9f2;
border-bottom: 1px solid #dcebe4;
}
.stop-read__heading {
display: flex;
align-items: center;
gap: 8px;
}
.stop-read__heading h4 {
margin: 0;
font-size: 15px;
font-weight: 700;
}
.stop-read__sequence {
display: inline-flex;
align-items: center;
justify-content: center;
min-width: 22px;
height: 22px;
padding: 0 4px;
color: #fff;
background: #0a9f6d;
border-radius: 6px;
font-size: 12px;
font-weight: 600;
}
.stop-read__customer {
margin-top: 6px;
color: #1f2a26;
font-size: 13px;
font-weight: 600;
overflow-wrap: anywhere;
}
.stop-read__section {
margin: 8px;
padding: 10px;
min-width: 0;
background: #fff;
border-radius: 8px;
}
.stop-read__section-title {
display: flex;
align-items: center;
gap: 8px;
margin: 0 0 4px;
padding-left: 7px;
border-left: 3px solid #0a9f6d;
color: #1f2a26;
font-size: 13px;
font-weight: 650;
}
.stop-read__section-title > span,
.stop-read__empty {
color: #8a9a93;
font-size: 12px;
font-weight: 400;
}
.stop-read__empty {
margin: 8px 0 0;
}
.fields {
display: grid;
grid-template-columns: repeat(2, minmax(0, 1fr));
column-gap: 16px;
padding: 0;
}
.fields > div {
display: flex;
flex-direction: column;
align-items: flex-start;
gap: 2px;
min-width: 0;
padding: 8px 0;
font-size: 13px;
line-height: 1.4;
border-bottom: 1px solid #eef4f1;
}
.fields span {
min-width: 0;
font-weight: 600;
color: #1f2a26;
overflow-wrap: anywhere;
}
.fields > .wide {
grid-column: 1 / -1;
white-space: pre-wrap;
}
small {
font-size: 11px;
font-weight: 400;
line-height: 1.3;
color: #8a9a93;
}
@media (max-width: 359px) {
.fields {
grid-template-columns: minmax(0, 1fr);
}
}
.product {
min-width: 0;
padding: 8px;
margin-top: 8px;
border: 1px solid #e4ece7;
border-radius: 8px;
background: #f7faf8;
}
.product-title {
display: flex;
flex-wrap: wrap;
gap: 6px;
align-items: center;
margin: 0 0 4px;
font-size: 14px;
font-weight: 650;
color: #1f2a26;
}
.product-title > span {
min-width: 0;
overflow-wrap: anywhere;
}
.product-hazards {
display: inline-flex;
flex-shrink: 0;
gap: 6px;
}
.product-title .product-index {
flex-shrink: 0;
min-width: 20px;
justify-content: center;
}
.contract-link {
min-height: 44px;
padding: 0;
color: #087f57;
text-align: left;
overflow-wrap: anywhere;
background: transparent;
border: 0;
}
</style>
<style lang="scss">
/* 弹窗定高,合同页签固定,正文由嵌入详情单独滚动。 */
.plan-contract-sheet.van-popup {
display: flex;
flex-direction: column;
height: 90vh;
height: 90dvh;
max-height: 90vh;
overflow: hidden;
}
.plan-contract-sheet__panel {
display: flex;
flex-direction: column;
flex: 1;
height: 0;
max-height: 90vh;
min-height: 0;
background: #f5f8f7;
}
.plan-contract-sheet__panel > .van-nav-bar {
flex-shrink: 0;
}
.plan-contract-sheet__panel .van-nav-bar__left {
min-width: 44px;
min-height: 44px;
}
.plan-contract-sheet__body {
display: flex;
flex-direction: column;
flex: 1;
height: 0;
min-height: 0;
padding: 0 16px calc(16px + env(safe-area-inset-bottom));
overflow: hidden;
overflow-wrap: anywhere;
-webkit-overflow-scrolling: touch;
}
.plan-contract-sheet__body .mp-contract-detail-page {
min-height: 0;
padding-bottom: 12px;
}
.plan-contract-sheet__body .mp-wv-detail-body {
padding-bottom: 0;
}
</style>