This commit is contained in:
zlwu committed 2026-08-27 19:38:01 +08:00
1 parent 4611dbc2b2
commit ebf006eeff
46 files changed
+36802 -20974

No files matched your search

@@ -1,8 +1,20 @@
<template>
<div class="panel dialog-list-panel pl-plan-product-table-wrap">
<div class="list-body list-wrap dialog-list-body-only">
<ListTable table-key="business-pl-plan-form-dialog-pl-plan-form-product-table" :data="products" stripe class="list-table pl-plan-product-table" empty-text="暂无产品">
<el-table-column label="序号" type="index" width="60" align="center" header-align="center" />
<ListTable
table-key="business-pl-plan-form-dialog-pl-plan-form-product-table"
:data="products"
stripe
class="list-table pl-plan-product-table"
empty-text="暂无产品"
>
<el-table-column
label="序号"
type="index"
width="60"
align="center"
header-align="center"
/>
<el-table-column label="产品名称" min-width="140" show-overflow-tooltip>
<template #default="{ row }">
<PlProductNameHazardCell
@@ -10,7 +22,13 @@
/>
</template>
</el-table-column>
<el-table-column label="别名" min-width="140" align="center" show-overflow-tooltip>
<el-table-column
v-if="!archiveCompact"
label="别名"
min-width="140"
align="center"
show-overflow-tooltip
>
<template #default="{ row }">
<div v-if="editableAliasBrand" class="line-meta-cell">
<el-select
@@ -44,7 +62,13 @@
<span v-else>{{ row.aliasName || '—' }}</span>
</template>
</el-table-column>
<el-table-column label="品牌" min-width="140" align="center" show-overflow-tooltip>
<el-table-column
v-if="!archiveCompact"
label="品牌"
min-width="140"
align="center"
show-overflow-tooltip
>
<template #default="{ row }">
<div v-if="editableAliasBrand" class="line-meta-cell">
<el-select
@@ -78,7 +102,12 @@
<span v-else>{{ formatBrandConstraintLabel(row.brandMode, row.brandName) }}</span>
</template>
</el-table-column>
<el-table-column label="型号/规格" min-width="120" show-overflow-tooltip>
<el-table-column
v-if="!archiveCompact"
label="型号/规格"
min-width="120"
show-overflow-tooltip
>
<template #default="{ row }">
{{ row.model || row.productModel || '—' }}
</template>
@@ -217,17 +246,18 @@
{{ formatPlanProductIoAmount(row.outboundQty, row.outboundPrice) }}
</template>
</el-table-column>
<el-table-column
v-if="showBrandQty"
label="品牌数量"
min-width="180"
show-overflow-tooltip
>
<el-table-column v-if="showBrandQty" label="品牌数量" min-width="180" show-overflow-tooltip>
<template #default="{ row }">
{{ formatBrandQtySummary(row.brandQtyRows) || '—' }}
</template>
</el-table-column>
<el-table-column prop="packageSpec" label="包装规格" min-width="150" align="center">
<el-table-column
v-if="!archiveCompact"
prop="packageSpec"
label="包装规格"
min-width="150"
align="center"
>
<template #default="{ row }">
<DictSelect
v-if="editablePackageDelivery"
@@ -243,7 +273,7 @@
</template>
</template>
</el-table-column>
<el-table-column label="送货方式" min-width="150" align="center">
<el-table-column v-if="!archiveCompact" label="送货方式" min-width="150" align="center">
<template #default="{ row }">
<DictSelect
v-if="editablePackageDelivery"
@@ -263,7 +293,11 @@
</el-table-column>
<el-table-column v-if="editableRemark" label="备注" min-width="140">
<template #default="{ row }">
<el-input v-model="row.remark" class="pl-plan-product-cell-control" placeholder="备注" />
<el-input
v-model="row.remark"
class="pl-plan-product-cell-control"
placeholder="备注"
/>
</template>
</el-table-column>
<el-table-column v-else prop="remark" label="备注" min-width="120" show-overflow-tooltip />
@@ -308,172 +342,166 @@
</template>
<script setup lang="ts">
import { Delete, Plus } from '@element-plus/icons-vue'
import type { PlanFormProductRow } from '@/composables/usePlContractToPlan'
import { getDeliveryMethodLabel } from '@/composables/usePlContractToPlan'
import {
applyBrandSelectChange,
applyManagedProductMetaToLines,
formatBrandConstraintLabel,
resolveLineProductName
} from '@/utils/crm-product-brand'
import { formatBrandQtySummary } from '@/utils/pl-display'
import PlProductNameHazardCell from '@/components/business/pl-product-name-hazard-cell/index.vue'
import ProductAliasBrandDialog from '@/components/business/product-alias-brand-dialog/index.vue'
import DictTag from '@/components/DictTag/index.vue'
import DictSelect from '@/components/DictSelect/index.vue'
import { useDictStore } from '@/store/modules/dict'
import { Delete, Plus } from '@element-plus/icons-vue'
import type { PlanFormProductRow } from '@/composables/usePlContractToPlan'
import { getDeliveryMethodLabel } from '@/composables/usePlContractToPlan'
import {
applyBrandSelectChange,
applyManagedProductMetaToLines,
formatBrandConstraintLabel,
resolveLineProductName
} from '@/utils/crm-product-brand'
import { formatBrandQtySummary } from '@/utils/pl-display'
import PlProductNameHazardCell from '@/components/business/pl-product-name-hazard-cell/index.vue'
import ProductAliasBrandDialog from '@/components/business/product-alias-brand-dialog/index.vue'
import DictTag from '@/components/DictTag/index.vue'
import DictSelect from '@/components/DictSelect/index.vue'
import { useDictStore } from '@/store/modules/dict'
const props = defineProps<{
products: PlanFormProductRow[]
showDelete?: boolean
showSelect?: boolean
/** 已加入运输计划的产品 ID,用于禁用合同预览中的「选择」按钮 */
selectedProductIds?: string[]
editableRemark?: boolean
editableQty?: boolean
/** 产品信息区:别名 / 品牌可改 */
editableAliasBrand?: boolean
/** 单位 / 包装规格 / 送货方式可下拉编辑(对齐报价单) */
editablePackageDelivery?: boolean
/** 新增/编辑弹窗默认不展示实际数量 */
showActualQty?: boolean
/** 展示归档品牌数量摘要(如:君正 12 / 红四方 13) */
showBrandQty?: boolean
/** 仅实际数量可编辑,计划数量只读(归档弹窗) */
editableActualQtyOnly?: boolean
/** 展示入库/出库数量列(不含价格) */
showInboundOutboundQty?: boolean
/** 展示入库/出库数量、单价与计算金额列 */
showArchiveIoFields?: boolean
/** 入库/出库数量与价格可编辑(归档弹窗) */
editableArchiveIoFields?: boolean
/** 归档:仅展示/编辑入库列(装货段) */
archiveIoInboundOnly?: boolean
/** 归档:仅展示/编辑出库列(送货段) */
archiveIoOutboundOnly?: boolean
/** 段次归档:入库/出库列统一展示为实际数量、单价、金额 */
archiveSegmentLabels?: boolean
}>()
const props = defineProps<{
products: PlanFormProductRow[]
showDelete?: boolean
showSelect?: boolean
/** 已加入运输计划的产品 ID,用于禁用合同预览中的「选择」按钮 */
selectedProductIds?: string[]
editableRemark?: boolean
editableQty?: boolean
/** 产品信息区:别名 / 品牌可改 */
editableAliasBrand?: boolean
/** 单位 / 包装规格 / 送货方式可下拉编辑(对齐报价单) */
editablePackageDelivery?: boolean
/** 新增/编辑弹窗默认不展示实际数量 */
showActualQty?: boolean
/** 展示归档品牌数量摘要(如:君正 12 / 红四方 13) */
showBrandQty?: boolean
/** 仅实际数量可编辑,计划数量只读(归档弹窗) */
editableActualQtyOnly?: boolean
/** 展示入库/出库数量列(不含价格) */
showInboundOutboundQty?: boolean
/** 展示入库/出库数量、单价与计算金额列 */
showArchiveIoFields?: boolean
/** 入库/出库数量与价格可编辑(归档弹窗) */
editableArchiveIoFields?: boolean
/** 归档:仅展示/编辑入库列(装货段) */
archiveIoInboundOnly?: boolean
/** 归档:仅展示/编辑出库列(送货段) */
archiveIoOutboundOnly?: boolean
/** 段次归档:入库/出库列统一展示为实际数量、单价、金额 */
archiveSegmentLabels?: boolean
/** 归档段表单:仅保留产品名称、单位、计划数量与归档列 */
archiveCompact?: boolean
}>()
const emit = defineEmits<{
remove: [index: number]
select: [row: PlanFormProductRow, index: number]
}>()
const emit = defineEmits<{
remove: [index: number]
select: [row: PlanFormProductRow, index: number]
}>()
const dictStore = useDictStore()
const dictStore = useDictStore()
const selectedProductIdSet = computed(
() => new Set((props.selectedProductIds || []).map(id => String(id)))
)
function getDeliveryMethodDisplay(method?: string) {
const label = dictStore.getLabel('crm_shfs', method || '')
if (label && label !== method) return label
return getDeliveryMethodLabel(method)
}
function isProductSelected(row: PlanFormProductRow) {
return selectedProductIdSet.value.has(String(row.productId))
}
/** 入库/出库金额:数量 × 单价,保留两位小数 */
function formatPlanProductIoAmount(
qty?: number | string | null,
price?: number | string | null
) {
if (qty == null || price == null || qty === '' || price === '') return '—'
const amount = Number(qty) * Number(price)
if (!Number.isFinite(amount)) return '—'
return amount.toFixed(2)
}
function handleAliasChange(row: PlanFormProductRow) {
row.productName = resolveLineProductName(row.standardProductName, row.aliasName)
}
function handleBrandChange(row: PlanFormProductRow, val: string | undefined | null) {
applyBrandSelectChange(row, val, row.brandOptions || [])
}
const aliasBrandManageVisible = ref(false)
const aliasBrandManageProductId = ref('')
const aliasBrandManageProductName = ref('')
const aliasBrandManageMode = ref<'alias' | 'brand'>('alias')
function openAliasBrandManage(row: PlanFormProductRow, mode: 'alias' | 'brand') {
if (!row.productId) return
aliasBrandManageProductId.value = String(row.productId)
aliasBrandManageProductName.value = String(row.standardProductName || row.productName || '')
aliasBrandManageMode.value = mode
aliasBrandManageVisible.value = true
}
function handleAliasBrandManaged(product: Record<string, any>) {
applyManagedProductMetaToLines(
props.products || [],
aliasBrandManageProductId.value,
product
const selectedProductIdSet = computed(
() => new Set((props.selectedProductIds || []).map((id) => String(id)))
)
const pid = aliasBrandManageProductId.value
for (const line of props.products || []) {
if (String(line.productId || '') !== pid) continue
line.productName = resolveLineProductName(line.standardProductName, line.aliasName)
function getDeliveryMethodDisplay(method?: string) {
const label = dictStore.getLabel('crm_shfs', method || '')
if (label && label !== method) return label
return getDeliveryMethodLabel(method)
}
function isProductSelected(row: PlanFormProductRow) {
return selectedProductIdSet.value.has(String(row.productId))
}
/** 入库/出库金额:数量 × 单价,保留两位小数 */
function formatPlanProductIoAmount(qty?: number | string | null, price?: number | string | null) {
if (qty == null || price == null || qty === '' || price === '') return '—'
const amount = Number(qty) * Number(price)
if (!Number.isFinite(amount)) return '—'
return amount.toFixed(2)
}
function handleAliasChange(row: PlanFormProductRow) {
row.productName = resolveLineProductName(row.standardProductName, row.aliasName)
}
function handleBrandChange(row: PlanFormProductRow, val: string | undefined | null) {
applyBrandSelectChange(row, val, row.brandOptions || [])
}
const aliasBrandManageVisible = ref(false)
const aliasBrandManageProductId = ref('')
const aliasBrandManageProductName = ref('')
const aliasBrandManageMode = ref<'alias' | 'brand'>('alias')
function openAliasBrandManage(row: PlanFormProductRow, mode: 'alias' | 'brand') {
if (!row.productId) return
aliasBrandManageProductId.value = String(row.productId)
aliasBrandManageProductName.value = String(row.standardProductName || row.productName || '')
aliasBrandManageMode.value = mode
aliasBrandManageVisible.value = true
}
function handleAliasBrandManaged(product: Record<string, any>) {
applyManagedProductMetaToLines(props.products || [], aliasBrandManageProductId.value, product)
const pid = aliasBrandManageProductId.value
for (const line of props.products || []) {
if (String(line.productId || '') !== pid) continue
line.productName = resolveLineProductName(line.standardProductName, line.aliasName)
}
}
}
</script>
<style scoped lang="scss">
.pl-plan-product-table-wrap {
margin-top: 8px;
.pl-plan-product-table-wrap {
margin-top: 8px;
/* 别名 / 品牌下拉与备注输入框同高、同字号 */
:deep(.pl-plan-product-cell-control) {
.el-input__wrapper,
.el-select__wrapper {
height: var(--el-component-custom-height, 36px);
min-height: var(--el-component-custom-height, 36px);
font-size: 14px;
/* 别名 / 品牌下拉与备注输入框同高、同字号 */
:deep(.pl-plan-product-cell-control) {
.el-input__wrapper,
.el-select__wrapper {
height: var(--el-component-custom-height, 36px);
min-height: var(--el-component-custom-height, 36px);
font-size: 14px;
}
.el-input__inner,
.el-select__selected-item,
.el-select__placeholder,
.el-select__input {
font-size: 14px;
}
}
.el-input__inner,
.el-select__selected-item,
.el-select__placeholder,
.el-select__input {
font-size: 14px;
.line-meta-cell {
display: flex;
align-items: center;
gap: 4px;
min-width: 0;
}
.line-meta-cell__control {
flex: 1;
min-width: 0;
}
.line-meta-cell__empty {
flex: 1;
min-width: 0;
}
.line-meta-cell__btn {
flex-shrink: 0;
padding: 4px;
}
}
.line-meta-cell {
display: flex;
align-items: center;
gap: 4px;
min-width: 0;
}
.line-meta-cell__control {
flex: 1;
min-width: 0;
}
.line-meta-cell__empty {
flex: 1;
min-width: 0;
}
.line-meta-cell__btn {
flex-shrink: 0;
padding: 4px;
}
}
</style>
<style lang="scss">
/* teleported 下拉挂到 body,需非 scoped;选项字号与输入框一致 */
.pl-plan-alias-brand-select-dropdown {
.el-select-dropdown__item {
font-size: 14px;
/* teleported 下拉挂到 body,需非 scoped;选项字号与输入框一致 */
.pl-plan-alias-brand-select-dropdown {
.el-select-dropdown__item {
font-size: 14px;
}
}
}
</style>