This commit is contained in:
zlwu committed 2026-08-30 09:30:02 +08:00
1 parent 16986f443e
commit 63a1209620
83 files changed
+1083168 -11413

No files matched your search

+16
View File
@@ -614,6 +614,8 @@ export interface PlanQuery {
planNo?: string
planType?: string
followStatus?: string
/** 排除的跟进状态,多个以英文逗号分隔 */
excludeFollowStatus?: string
transportStatus?: string
archiveStatus?: string
customerName?: string
@@ -790,11 +792,23 @@ export interface PlanArchiveFreightBlock {
hasInvoice?: number
}
export interface PlanArchiveStopFeedbackAttachmentItem {
stopType: 'load' | 'delivery'
stopId: string
attachmentUrls: string[]
}
export interface PlanArchiveFeedbacksBlock {
driverStops?: PlanArchiveStopFeedbackAttachmentItem[]
siteStops?: PlanArchiveStopFeedbackAttachmentItem[]
}
export interface PlanArchiveBody {
products?: PlanArchiveProductItem[]
load?: PlanArchiveLoadBlock
deliveries?: PlanArchiveDeliveryBlock[]
freight?: PlanArchiveFreightBlock
feedbacks?: PlanArchiveFeedbacksBlock
}
export interface PlanDriverFeedbackProductItem {
@@ -885,6 +899,8 @@ export const planApi = {
request.get<PlanArrangeInfo>(`/transport/plan/${id}/arrange-info`),
archive: (id: string, data?: PlanArchiveBody) =>
request.post<Plan>(`/transport/plan/${id}/archive`, data),
archiveDraft: (id: string, data: PlanArchiveBody) =>
request.post<Plan>(`/transport/plan/${id}/archive-draft`, data),
updateDriverFeedback: (id: string, data: PlanDriverFeedbackUpdateBody) =>
request.patch<Plan>(`/transport/plan/${id}/driver-feedback`, data),
updateSiteFeedback: (id: string, linkId: string, data: PlanSiteFeedbackUpdateBody) =>
@@ -1,7 +1,7 @@
<template>
<SystemViewDialog
v-model:visible="innerVisible"
title="查看关联数据"
title="查看出入库单"
:icon="Link"
:sections="sections"
:loading="loading"
@@ -22,12 +22,13 @@
import { computed } from 'vue'
import { Link } from '@element-plus/icons-vue'
import SystemViewDialog from '@/components/business/system-view-dialog/index.vue'
import type { InventoryRelatedData } from '@/api/db/inventory'
import type { InventoryRecord, InventoryRelatedData } from '@/api/db/inventory'
import { buildInventoryRelatedSections } from '@/components/business/db/db-related-view'
const props = defineProps<{
visible: boolean
loading?: boolean
inventory?: InventoryRecord | null
data: InventoryRelatedData
}>()
@@ -40,5 +41,5 @@
set: (val) => emit('update:visible', val)
})
const sections = computed(() => buildInventoryRelatedSections(props.data))
const sections = computed(() => buildInventoryRelatedSections(props.data, props.inventory))
</script>
@@ -1,7 +1,7 @@
<template>
<SystemViewDialog
v-model:visible="innerVisible"
title="查看关联数据"
title="查看计划"
:icon="Link"
:sections="sections"
:loading="loading"
@@ -22,12 +22,13 @@
import { computed } from 'vue'
import { Link } from '@element-plus/icons-vue'
import SystemViewDialog from '@/components/business/system-view-dialog/index.vue'
import type { PlanRelatedData } from '@/api/db/plans'
import type { Plan, PlanRelatedData } from '@/api/db/plans'
import { buildPlanRelatedSections } from '@/components/business/db/db-related-view'
const props = defineProps<{
visible: boolean
loading?: boolean
plan?: Plan | null
data: PlanRelatedData
}>()
@@ -40,5 +41,5 @@
set: (val) => emit('update:visible', val)
})
const sections = computed(() => buildPlanRelatedSections(props.data))
const sections = computed(() => buildPlanRelatedSections(props.data, props.plan))
</script>
@@ -1,7 +1,7 @@
<template>
<SystemViewDialog
v-model:visible="innerVisible"
title="查看关联数据"
title="查看地磅单"
:icon="Link"
:sections="sections"
:loading="loading"
@@ -1,6 +1,6 @@
import type { Plan, PlanInventoryRecord, PlanRelatedData, PlanWeighingRecord } from '@/api/db/plans'
import type { InventoryRecord, InventoryRelatedData, InventoryWeighingRecord } from '@/api/db/inventory'
import type { WeighingRelatedData } from '@/api/db/weighing'
import type { WeighingRecord, WeighingRelatedData } from '@/api/db/weighing'
import type { TagType, ViewField, ViewSection } from '@/components/business/system-view-dialog/index.vue'
export function businessTypeTagType(businessType: string): TagType {
@@ -85,7 +85,7 @@ export function buildInventoryViewSection(
}
export function buildWeighingViewSection(
record: PlanWeighingRecord | InventoryWeighingRecord,
record: PlanWeighingRecord | InventoryWeighingRecord | WeighingRecord,
title = '地磅单'
): ViewSection {
const fields: ViewField[] = [
@@ -161,17 +161,22 @@ function mergePlanRelatedItems(data: PlanRelatedData): MergedPlanRelatedItem[] {
})
}
export function buildPlanRelatedSections(data: PlanRelatedData): ViewSection[] {
export function buildPlanRelatedSections(
data: PlanRelatedData,
plan?: Plan | null
): ViewSection[] {
const sections: ViewSection[] = []
if (plan) sections.push(buildPlanViewSection(plan))
const items = mergePlanRelatedItems(data)
if (!items.length) {
return [
{
title: '关联数据',
fieldLayout: 'table',
tableMode: 'triple',
fields: [{ label: '说明', value: '暂无关联数据', span: 'full' }]
}
]
sections.push({
title: '关联数据',
fieldLayout: 'table',
tableMode: 'triple',
fields: [{ label: '说明', value: '暂无关联数据', span: 'full' }]
})
return sections
}
const inventoryCount = items.filter((item) => item.type === 'inventory').length
@@ -179,48 +184,55 @@ export function buildPlanRelatedSections(data: PlanRelatedData): ViewSection[] {
let inventoryIndex = 0
let weighingIndex = 0
return items.map((item) => {
items.forEach((item) => {
if (item.type === 'inventory') {
const title = sectionTitle('出入库单', inventoryIndex, inventoryCount)
inventoryIndex += 1
return buildInventoryViewSection(item, title)
sections.push(buildInventoryViewSection(item, title))
return
}
const title = sectionTitle('地磅单', weighingIndex, weighingCount)
weighingIndex += 1
return buildWeighingViewSection(item, title)
sections.push(buildWeighingViewSection(item, title))
})
return sections
}
export function buildInventoryRelatedSections(data: InventoryRelatedData): ViewSection[] {
export function buildInventoryRelatedSections(
data: InventoryRelatedData,
inventory?: InventoryRecord | null
): ViewSection[] {
const sections: ViewSection[] = []
if (inventory) sections.push(buildInventoryViewSection(inventory))
if (data.plan) sections.push(buildPlanViewSection(data.plan))
if (data.weighing) sections.push(buildWeighingViewSection(data.weighing))
if (!sections.length) {
return [
{
title: '关联数据',
fieldLayout: 'table',
tableMode: 'triple',
fields: [{ label: '说明', value: '暂无关联数据', span: 'full' }]
}
]
if (!data.plan && !data.weighing) {
sections.push({
title: '关联数据',
fieldLayout: 'table',
tableMode: 'triple',
fields: [{ label: '说明', value: '暂无关联数据', span: 'full' }]
})
}
return sections
}
export function buildWeighingRelatedSections(data: WeighingRelatedData): ViewSection[] {
export function buildWeighingRelatedSections(
data: WeighingRelatedData,
weighing?: WeighingRecord | null
): ViewSection[] {
const sections: ViewSection[] = []
if (weighing) sections.push(buildWeighingViewSection(weighing))
if (data.plan) sections.push(buildPlanViewSection(data.plan))
if (data.inventory) sections.push(buildInventoryViewSection(data.inventory))
if (!sections.length) {
return [
{
title: '关联数据',
fieldLayout: 'table',
tableMode: 'triple',
fields: [{ label: '说明', value: '暂无关联数据', span: 'full' }]
}
]
if (!data.plan && !data.inventory) {
sections.push({
title: '关联数据',
fieldLayout: 'table',
tableMode: 'triple',
fields: [{ label: '说明', value: '暂无关联数据', span: 'full' }]
})
}
return sections
}
@@ -39,17 +39,23 @@
<PlPlanStopsSplitShell :show-balance="false">
<template #load>
<PlPlanArchiveSegmentBlock
ref="loadSegmentRef"
stop-type="load"
:meta="loadArchiveMeta"
:view-products="loadViewProducts"
:products="loadProductRows"
archive-mode="inbound"
:show-stop-feedback="showStopFeedback"
editable-attachments
:generate-dibang="plan.load?.generateDibang"
:dibang-rows="loadDibangRows"
:driver-feedback="resolveDriverStopFeedback('load', loadStopId)"
:site-feedback="resolveSiteStopFeedback('load', loadStopId)"
:fallback-remark="transport?.feedbackRemark"
:driver-attachment-urls="getFeedbackAttachmentCsv('load', loadStopId, 'driver')"
:site-attachment-urls="getFeedbackAttachmentCsv('load', loadStopId, 'site')"
@update:driver-attachment-urls="setFeedbackAttachmentCsv('load', loadStopId, 'driver', $event)"
@update:site-attachment-urls="setFeedbackAttachmentCsv('load', loadStopId, 'site', $event)"
/>
</template>
<template #delivery>
@@ -72,18 +78,28 @@
class="pl-plan-view-delivery-block"
>
<PlPlanArchiveSegmentBlock
:ref="(el) => setDeliverySegmentRef(index, el)"
stop-type="delivery"
:meta="block.meta"
:view-products="getDeliveryViewProducts(index)"
:products="block.products"
archive-mode="outbound"
:show-stop-feedback="showStopFeedback"
editable-attachments
:feedback-stop-label="deliveryBlocks.length > 1 ? `送货 #${index + 1}` : '送货'"
:generate-dibang="plan.deliveries?.[index]?.generateDibang"
:dibang-rows="resolveDeliveryDibangRows(index)"
:driver-feedback="resolveDriverStopFeedback('delivery', block.stopId)"
:site-feedback="resolveSiteStopFeedback('delivery', block.stopId)"
:fallback-remark="transport?.feedbackRemark"
:driver-attachment-urls="getFeedbackAttachmentCsv('delivery', block.stopId, 'driver')"
:site-attachment-urls="getFeedbackAttachmentCsv('delivery', block.stopId, 'site')"
@update:driver-attachment-urls="
setFeedbackAttachmentCsv('delivery', block.stopId, 'driver', $event)
"
@update:site-attachment-urls="
setFeedbackAttachmentCsv('delivery', block.stopId, 'site', $event)
"
/>
</article>
</template>
@@ -194,6 +210,13 @@
<el-button @click="innerVisible = false">
<el-icon><Close /></el-icon>取消
</el-button>
<el-button
v-if="!isAdjustMode"
:loading="draftLoading"
@click="handleSaveDraft"
>
<el-icon><Document /></el-icon>暂存
</el-button>
<el-button type="primary" :loading="submitLoading" @click="handleSubmit">
<el-icon><Check /></el-icon>{{ submitLabel }}
</el-button>
@@ -203,7 +226,7 @@
</template>
<script setup lang="ts">
import { Check, Close } from '@element-plus/icons-vue'
import { Check, Close, Document } from '@element-plus/icons-vue'
import { fetchProductDetail, type ProductDetail } from '@/api/crm/product'
import {
inboundOrderApi,
@@ -211,6 +234,8 @@
planApi,
type Plan,
type PlanArchiveBody,
type PlanArchiveFeedbacksBlock,
type PlanArchiveStopFeedbackAttachmentItem,
type PlanDelivery,
type PlanProduct,
type PlanStopProduct,
@@ -244,6 +269,7 @@
resolveStopProductsForView,
type PlanStopProductFormRow
} from '@/utils/pl-plan-stop-form'
import { isPlInternalCustomerName } from '@/utils/pl-internal-customer'
const props = defineProps<{
visible: boolean
@@ -262,6 +288,7 @@
const loading = ref(false)
const submitLoading = ref(false)
const draftLoading = ref(false)
const activeTab = ref<'archive' | 'overview'>('archive')
const tabsRef = ref<InstanceType<typeof PlPlanViewTabs> | null>(null)
const vehicleViewVisible = ref(false)
@@ -287,6 +314,9 @@
}>
>([])
const archiveDeliveryTabIndex = ref(0)
const loadSegmentRef = ref<InstanceType<typeof PlPlanArchiveSegmentBlock> | null>(null)
const deliverySegmentRefs = ref<Array<InstanceType<typeof PlPlanArchiveSegmentBlock> | null>>([])
const feedbackAttachmentEdits = reactive<Record<string, string>>({})
const canSubmitStopArchive = computed(
() =>
Boolean(plan.value.load?.id) &&
@@ -395,7 +425,7 @@
function getDeliveryViewProducts(index: number): PlanStopProductFormRow[] {
const delivery = plan.value?.deliveries?.[index]
if (delivery) {
const mapped = mapDeliveriesFromApi([delivery], plan.value?.load?.customerName)[0]
const mapped = mapDeliveriesFromApi([delivery])[0]
return resolveStopProductsForView(mapped.products, productRows.value)
}
const legacy = mapLegacyPlanToStops(plan.value || ({} as Plan)).deliveries[index]
@@ -455,8 +485,139 @@
)
}
type FeedbackAttachmentKind = 'driver' | 'site'
function feedbackAttachmentKey(
stopType: 'load' | 'delivery',
stopId: string,
kind: FeedbackAttachmentKind
) {
return `${stopType}:${stopId}:${kind}`
}
function parseAttachmentCsv(csv: string) {
return csv
.split(',')
.map((item) => item.trim())
.filter(Boolean)
}
function resolveFeedbackAttachmentCsv(
stopType: 'load' | 'delivery',
stopId: string,
kind: FeedbackAttachmentKind
) {
const feedback =
kind === 'driver'
? resolveDriverStopFeedback(stopType, stopId)
: resolveSiteStopFeedback(stopType, stopId)
return (feedback?.attachmentUrls || []).join(',')
}
function initFeedbackAttachmentEdits() {
Object.keys(feedbackAttachmentEdits).forEach((key) => {
delete feedbackAttachmentEdits[key]
})
const loadId = loadStopId.value
if (loadId) {
feedbackAttachmentEdits[feedbackAttachmentKey('load', loadId, 'driver')] =
resolveFeedbackAttachmentCsv('load', loadId, 'driver')
if (shouldCollectSiteFeedbackAttachments('load', loadId)) {
feedbackAttachmentEdits[feedbackAttachmentKey('load', loadId, 'site')] =
resolveFeedbackAttachmentCsv('load', loadId, 'site')
}
}
deliveryBlocks.value.forEach((block) => {
if (!block.stopId) return
feedbackAttachmentEdits[feedbackAttachmentKey('delivery', block.stopId, 'driver')] =
resolveFeedbackAttachmentCsv('delivery', block.stopId, 'driver')
if (shouldCollectSiteFeedbackAttachments('delivery', block.stopId)) {
feedbackAttachmentEdits[feedbackAttachmentKey('delivery', block.stopId, 'site')] =
resolveFeedbackAttachmentCsv('delivery', block.stopId, 'site')
}
})
}
function shouldCollectSiteFeedbackAttachments(
stopType: 'load' | 'delivery',
stopId: string
) {
if (!stopId) return false
const customerName =
stopType === 'load'
? loadArchiveMeta.value.customerName
: deliveryBlocks.value.find((block) => block.stopId === stopId)?.customerName
return isPlInternalCustomerName(customerName)
}
function getFeedbackAttachmentCsv(
stopType: 'load' | 'delivery',
stopId: string,
kind: FeedbackAttachmentKind
) {
if (!stopId) return ''
const key = feedbackAttachmentKey(stopType, stopId, kind)
if (key in feedbackAttachmentEdits) {
return feedbackAttachmentEdits[key]
}
return resolveFeedbackAttachmentCsv(stopType, stopId, kind)
}
function setFeedbackAttachmentCsv(
stopType: 'load' | 'delivery',
stopId: string,
kind: FeedbackAttachmentKind,
csv: string
) {
if (!stopId) return
feedbackAttachmentEdits[feedbackAttachmentKey(stopType, stopId, kind)] = csv
}
function setDeliverySegmentRef(index: number, el: unknown) {
deliverySegmentRefs.value[index] = (el as InstanceType<typeof PlPlanArchiveSegmentBlock>) || null
}
function hasFeedbackAttachmentUploading() {
const refs = [loadSegmentRef.value, ...deliverySegmentRefs.value].filter(Boolean)
return refs.some((refItem) => refItem?.hasAttachmentUploading?.())
}
function collectFeedbackAttachmentsForSubmit(): PlanArchiveFeedbacksBlock {
const driverStops: PlanArchiveStopFeedbackAttachmentItem[] = []
const siteStops: PlanArchiveStopFeedbackAttachmentItem[] = []
const appendStop = (
stopType: 'load' | 'delivery',
stopId: string,
kind: FeedbackAttachmentKind,
target: PlanArchiveStopFeedbackAttachmentItem[]
) => {
if (!stopId) return
if (kind === 'site' && !shouldCollectSiteFeedbackAttachments(stopType, stopId)) return
target.push({
stopType,
stopId,
attachmentUrls: parseAttachmentCsv(getFeedbackAttachmentCsv(stopType, stopId, kind))
})
}
if (loadStopId.value) {
appendStop('load', loadStopId.value, 'driver', driverStops)
appendStop('load', loadStopId.value, 'site', siteStops)
}
deliveryBlocks.value.forEach((block) => {
appendStop('delivery', block.stopId, 'driver', driverStops)
appendStop('delivery', block.stopId, 'site', siteStops)
})
return { driverStops, siteStops }
}
function buildDeliveryArchiveMeta(delivery: PlanDelivery): ArchiveSegmentMeta {
const mappedRows = mapDeliveriesFromApi([delivery], plan.value?.load?.customerName)
const mappedRows = mapDeliveriesFromApi([delivery])
const mapped = mappedRows[0]
return {
customerId: mapped.customerId,
@@ -989,6 +1150,10 @@
loadProductRows.value = []
deliveryBlocks.value = []
archiveDeliveryTabIndex.value = 0
deliverySegmentRefs.value = []
Object.keys(feedbackAttachmentEdits).forEach((key) => {
delete feedbackAttachmentEdits[key]
})
Object.assign(formData, {
hasFreight: 1,
distanceKm: null,
@@ -1072,6 +1237,7 @@
}
syncMultiStopBrandActualQty()
await applyFreightPrefill(data)
initFeedbackAttachmentEdits()
} catch (error) {
innerVisible.value = false
const message = error instanceof Error ? error.message : '加载运输计划失败'
@@ -1089,6 +1255,109 @@
resetState()
}
function toOptionalNumber(value: unknown): number | undefined {
if (value == null || value === '') return undefined
const n = Number(value)
return Number.isFinite(n) ? n : undefined
}
function buildArchiveBody(options?: { allowEmptyQty?: boolean }): PlanArchiveBody {
const allowEmptyQty = options?.allowEmptyQty === true
const mapBrandQtys = (row: PlanFormProductRow) =>
(row.brandQtyRows || [])
.filter((item) => Number(item.qty) > 0)
.map((item) => ({
brandId: item.brandId,
brandName: item.brandName,
qty: Number(item.qty),
unitPrice:
(item as { price?: number }).price != null
? Number((item as { price?: number }).price)
: undefined
}))
const brandProducts = collectBrandProductsForSubmit()
return {
load: {
stopId: plan.value.load!.id!,
products: loadProductRows.value.map((row) => ({
id: row.id!,
inboundQty: allowEmptyQty
? toOptionalNumber(row.inboundQty)
: Number(row.inboundQty ?? 0),
inboundPrice: row.inboundPrice != null ? Number(row.inboundPrice) : undefined,
brandQtys: mapBrandQtys(row)
}))
},
deliveries: deliveryBlocks.value.map((block) => ({
stopId: block.stopId,
products: block.products.map((row) => ({
id: row.id!,
outboundQty: allowEmptyQty
? toOptionalNumber(row.outboundQty)
: Number(row.outboundQty ?? 0),
outboundPrice: row.outboundPrice != null ? Number(row.outboundPrice) : undefined,
brandQtys: mapBrandQtys(row)
}))
})),
...(brandProducts.length ? { products: brandProducts } : {}),
freight: {
hasFreight: formData.hasFreight,
freightRemark: formData.freightRemark || undefined,
...(formData.hasFreight === 1
? {
distanceKm: formData.distanceKm ?? undefined,
freightType: formData.freightType,
freightPrice:
formData.freightType === 'by_weight'
? (freightCalc.freightPrice.value ?? undefined)
: undefined,
freightAmount:
freightCalc.calculatedFreight.value ||
freightCalc.freightAmount.value ||
undefined,
transportQty:
formData.freightType === 'by_weight'
? (freightCalc.transportQty.value ?? undefined)
: undefined
}
: {})
},
...(plan.value.transportId ? { feedbacks: collectFeedbackAttachmentsForSubmit() } : {})
}
}
async function handleSaveDraft() {
if (isAdjustMode.value) return
if (!canSubmitStopArchive.value) {
ElMessage.warning('缺少装货/送货段数据,请先完成运输安排后再暂存')
return
}
if (hasFeedbackAttachmentUploading()) {
ElMessage.warning('附件正在上传,请稍候再暂存')
return
}
syncSegmentBrandTotals(loadProductRows.value, 'inbound')
deliveryBlocks.value.forEach((block) => syncSegmentBrandTotals(block.products, 'outbound'))
syncMultiStopBrandActualQty()
draftLoading.value = true
try {
const body = buildArchiveBody({ allowEmptyQty: true })
await planApi.archiveDraft(props.planId, body)
plan.value.archiveStatus = 'draft'
ElMessage.success('已暂存')
emit('success')
innerVisible.value = false
} catch (e: unknown) {
const message = e instanceof Error ? e.message : '暂存失败'
ElMessage.error(message)
} finally {
draftLoading.value = false
}
}
async function handleSubmit() {
if (!canSubmitStopArchive.value) {
ElMessage.warning('缺少装货/送货段数据,请先完成运输安排后再归档')
@@ -1130,7 +1399,6 @@
return
}
const brandProducts = collectBrandProductsForSubmit()
if (
formData.hasFreight === 1 &&
formData.freightType === 'by_weight' &&
@@ -1154,73 +1422,14 @@
}
}
if (hasFeedbackAttachmentUploading()) {
ElMessage.warning('附件正在上传,请稍候再保存')
return
}
submitLoading.value = true
try {
const body: PlanArchiveBody = {
load: {
stopId: plan.value.load!.id!,
products: loadProductRows.value.map((row) => ({
id: row.id!,
inboundQty: Number(row.inboundQty ?? 0),
inboundPrice: row.inboundPrice != null ? Number(row.inboundPrice) : undefined,
brandQtys: (row.brandQtyRows || [])
.filter((item) => Number(item.qty) > 0)
.map((item) => ({
brandId: item.brandId,
brandName: item.brandName,
qty: Number(item.qty),
unitPrice:
(item as { price?: number }).price != null
? Number((item as { price?: number }).price)
: undefined
}))
}))
},
deliveries: deliveryBlocks.value.map((block) => ({
stopId: block.stopId,
products: block.products.map((row) => ({
id: row.id!,
outboundQty: Number(row.outboundQty ?? 0),
outboundPrice: row.outboundPrice != null ? Number(row.outboundPrice) : undefined,
brandQtys: (row.brandQtyRows || [])
.filter((item) => Number(item.qty) > 0)
.map((item) => ({
brandId: item.brandId,
brandName: item.brandName,
qty: Number(item.qty),
unitPrice:
(item as { price?: number }).price != null
? Number((item as { price?: number }).price)
: undefined
}))
}))
})),
...(brandProducts.length ? { products: brandProducts } : {}),
freight: {
hasFreight: formData.hasFreight,
freightRemark: formData.freightRemark || undefined,
...(formData.hasFreight === 1
? {
distanceKm: formData.distanceKm ?? undefined,
freightType: formData.freightType,
freightPrice:
formData.freightType === 'by_weight'
? (freightCalc.freightPrice.value ?? undefined)
: undefined,
freightAmount:
freightCalc.calculatedFreight.value ||
freightCalc.freightAmount.value ||
undefined,
transportQty:
formData.freightType === 'by_weight'
? (freightCalc.transportQty.value ?? undefined)
: undefined
}
: {})
}
}
await planApi.archive(props.planId, body)
await planApi.archive(props.planId, buildArchiveBody())
ElMessage.success(isAdjustMode.value ? '保存成功' : '归档成功')
tabsRef.value?.reload()
emit('success')
@@ -1409,8 +1618,8 @@
<style lang="scss">
.el-dialog.pl-plan-archive-dialog.dialog-form-layout {
width: calc(100vw - 48px) !important;
max-width: calc(100vw - 48px);
width: min(2000px, calc(100vw - 48px)) !important;
max-width: min(2000px, calc(100vw - 48px));
max-height: calc(100vh - 48px);
}
</style>
@@ -28,6 +28,7 @@
<PlPlanStopFeedbackPanel
v-if="showStopFeedback"
ref="feedbackPanelRef"
:stop-label="feedbackStopLabel"
:customer-name="meta.customerName"
:generate-dibang="generateDibang"
@@ -35,6 +36,11 @@
:driver-feedback="driverFeedback"
:site-feedback="siteFeedback"
:fallback-remark="fallbackRemark"
:editable-attachments="editableAttachments"
:driver-attachment-urls="driverAttachmentUrls"
:site-attachment-urls="siteAttachmentUrls"
@update:driver-attachment-urls="emit('update:driverAttachmentUrls', $event)"
@update:site-attachment-urls="emit('update:siteAttachmentUrls', $event)"
/>
<section class="pl-archive-segment-form">
@@ -169,8 +175,24 @@
driverFeedback?: TransportStopFeedback | null
siteFeedback?: TransportStopFeedback | null
fallbackRemark?: string | null
editableAttachments?: boolean
driverAttachmentUrls?: string
siteAttachmentUrls?: string
}>()
const emit = defineEmits<{
'update:driverAttachmentUrls': [value: string]
'update:siteAttachmentUrls': [value: string]
}>()
const feedbackPanelRef = ref<InstanceType<typeof PlPlanStopFeedbackPanel> | null>(null)
function hasAttachmentUploading() {
return Boolean(feedbackPanelRef.value?.hasAttachmentUploading?.())
}
defineExpose({ hasAttachmentUploading })
const dictStore = useDictStore()
const customerLabel = computed(() => (props.stopType === 'load' ? '装货客户' : '送货客户'))
@@ -2,7 +2,7 @@
<el-dialog
v-model="visibleProxy"
title="上传危化品证书"
width="min(960px, calc(100vw - 80px))"
width="min(2000px, calc(100vw - 80px))"
align-center
destroy-on-close
append-to-body
@@ -156,13 +156,16 @@
<div class="pl-plan-dibang-row">
<el-checkbox
:model-value="delivery.generateDibang === 1"
:disabled="isDibangLocked"
:disabled="isPlInternalCustomerName(delivery.customerName)"
@update:model-value="(checked) => handleDibangToggle(index, checked)"
>
生成地磅单({{ directionLabel(delivery.dibangDirection) }})
</el-checkbox>
<span v-if="isDibangLocked" class="pl-plan-dibang-row__hint">
装货客户为内部客户时默认勾选
<span
v-if="isPlInternalCustomerName(delivery.customerName)"
class="pl-plan-dibang-row__hint"
>
本段客户为内部客户时默认勾选
</span>
</div>
</el-form-item>
@@ -208,6 +211,7 @@
import PlPlanStopProductTable from '@/components/business/pl-plan-stop-product-table/index.vue'
import {
createEmptyDeliveryForm,
resolveStopDibangDefaults,
sumStopProductsPlanQty,
type PlanDeliveryForm
} from '@/utils/pl-plan-stop-form'
@@ -217,7 +221,6 @@
const props = withDefaults(
defineProps<{
modelValue: PlanDeliveryForm[]
loadCustomerName?: string
tabMode?: boolean
readonly?: boolean
compactProducts?: boolean
@@ -226,7 +229,6 @@
showSplitHint?: boolean
}>(),
{
loadCustomerName: '',
tabMode: true,
readonly: false,
compactProducts: true,
@@ -252,7 +254,6 @@
const activeIndex = ref(0)
const customerOptionsByIndex = ref<Record<number, CustomerOptionRow[]>>({})
const customerOptionsLoading = ref<Record<number, boolean>>({})
const isDibangLocked = computed(() => isPlInternalCustomerName(props.loadCustomerName))
watch(
() => props.modelValue.length,
@@ -304,7 +305,7 @@
const nextSeq = props.modelValue.length + 1
emit('update:modelValue', resequence([
...props.modelValue,
createEmptyDeliveryForm(nextSeq, props.loadCustomerName)
createEmptyDeliveryForm(nextSeq)
]))
activeIndex.value = props.modelValue.length
emit('add-delivery')
@@ -313,7 +314,7 @@
function removeDelivery(index: number) {
const next = props.modelValue.filter((_, i) => i !== index)
emit('update:modelValue', resequence(
next.length ? next : [createEmptyDeliveryForm(1, props.loadCustomerName)]
next.length ? next : [createEmptyDeliveryForm(1)]
))
if (activeIndex.value >= index && activeIndex.value > 0) {
activeIndex.value -= 1
@@ -474,10 +475,13 @@
(item) => String(item.id) === String(customerId)
)
const customerName = customer?.customerName || ''
const defaults = resolveStopDibangDefaults(customerName, 'delivery')
patchDelivery(index, {
customerId: String(customerId),
customerName,
contracts: [],
generateDibang: defaults.generateDibang,
dibangDirection: defaults.dibangDirection,
address: '',
lng: null,
lat: null,
@@ -511,7 +515,8 @@
function handleDibangToggle(index: number, checked: boolean) {
const delivery = props.modelValue[index]
const direction = isDibangLocked.value ? 'inbound' : delivery.dibangDirection || 'none'
const isInternal = isPlInternalCustomerName(delivery.customerName)
const direction = isInternal ? 'inbound' : delivery.dibangDirection || 'none'
patchDelivery(index, {
generateDibang: checked ? 1 : 0,
dibangDirection: checked ? direction : 'none'
@@ -22,7 +22,7 @@
>
<template #error>
<div class="pl-plan-document-attachment-cell__placeholder is-clickable is-common-thumb">
<el-icon :size="16" color="#10b981"><Picture /></el-icon>
<el-icon :size="18" color="#10b981"><Picture /></el-icon>
</div>
</template>
</el-image>
@@ -31,7 +31,7 @@
class="pl-plan-document-attachment-cell__placeholder is-clickable"
:class="{ 'is-common-thumb': usePlaceholderThumb }"
>
<el-icon :size="16" :color="usePlaceholderThumb ? '#10b981' : item.isPdf ? '#0284c7' : '#10b981'">
<el-icon :size="18" :color="usePlaceholderThumb ? '#10b981' : item.isPdf ? '#0284c7' : '#10b981'">
<Picture v-if="usePlaceholderThumb || item.isImage" />
<Document v-else />
</el-icon>
@@ -185,7 +185,7 @@
display: flex;
flex-direction: column;
align-items: center;
width: 56px;
width: 72px;
}
.pl-plan-document-attachment-cell__thumb {
@@ -193,11 +193,11 @@
display: flex;
align-items: center;
justify-content: center;
width: 56px;
height: 40px;
width: 72px;
height: 52px;
overflow: hidden;
border: 1px solid var(--border, #d9e8e2);
border-radius: 6px;
border-radius: 8px;
background: var(--table-head, #f8fafc);
}
@@ -237,24 +237,24 @@
.pl-plan-document-attachment-cell__ext {
margin-top: 2px;
font-size: 9px;
font-size: 10px;
line-height: 1;
color: #64748b;
}
.pl-plan-document-attachment-cell__download {
position: absolute;
right: 1px;
top: 1px;
right: 2px;
top: 2px;
z-index: 2;
width: 16px;
height: 16px;
width: 18px;
height: 18px;
border-radius: 50%;
background: #fff;
border: 1px solid #e2e8f0;
color: #1e293b;
cursor: pointer;
font-size: 10px;
font-size: 11px;
&:hover {
color: #1ca851;
@@ -268,10 +268,10 @@
right: 0;
bottom: 0;
left: 0;
padding: 1px 2px;
padding: 2px 3px;
background: rgba(15, 23, 42, 0.62);
color: #fff;
font-size: 10px;
font-size: 11px;
line-height: 1.2;
text-align: center;
word-break: keep-all;
@@ -98,7 +98,7 @@
<el-option
v-for="item in vehicleList"
:key="item.id"
:label="item.licensePlate"
:label="formatPlVehiclePlateOptionLabel(item.licensePlate, item.trailerNo)"
:value="item.id"
/>
</el-select>
@@ -226,7 +226,6 @@
<PlPlanDeliverySection
ref="deliverySectionRef"
v-model="deliveryForms"
:load-customer-name="loadForm.customerName"
tab-mode
compact-products
:qty-unit-label="planQtyUnitLabel"
@@ -365,7 +364,6 @@
mergePlanProductsFromLoadMirror,
sumStopProductsPlanQty,
syncDeliveriesProductsFromLoad,
syncDeliveryDibangFromLoad,
type PlanDeliveryForm,
type PlanLoadForm
} from '@/utils/pl-plan-stop-form'
@@ -377,6 +375,7 @@
initLineBrandMetaFromProduct,
prepareLineAliasAndBrandForSubmit
} from '@/utils/crm-product-brand'
import { formatPlVehiclePlateOptionLabel } from '@/utils/pl-display'
import {
buildMissingHazardCertReadyMessage,
enrichPlanProductsHazardFromCrm
@@ -948,7 +947,7 @@
stopFormsReady.value = false
if (data.load || data.deliveries?.length) {
loadForm.value = mapLoadFromApi(data.load)
deliveryForms.value = mapDeliveriesFromApi(data.deliveries, data.load?.customerName)
deliveryForms.value = mapDeliveriesFromApi(data.deliveries)
} else {
const legacy = mapLegacyPlanToStops(data)
loadForm.value = legacy.load
@@ -995,14 +994,6 @@
{ deep: true }
)
watch(
() => loadForm.value.customerName,
(loadCustomerName) => {
if (!stopFormsReady.value) return
deliveryForms.value = syncDeliveryDibangFromLoad(deliveryForms.value, loadCustomerName)
}
)
function openCustomerSelector(side: CustomerSide, deliveryIndex = 0) {
customerSelectorSide.value = side
customerSelectorDeliveryIndex.value = deliveryIndex
@@ -1691,27 +1682,29 @@
}
async function handleSubmit(mode: 'save' | 'saveAndArrange' | 'rearrange' = 'save') {
// 必须在 await validate 之前置位,避免连点并发多次 createFull
if (submitLoading.value) return
const valid = await basicFormRef.value?.validate().catch(() => false)
if (!valid || !validateBusinessRules()) return
if (mode === 'saveAndArrange' || mode === 'rearrange') {
const missing = getArrangePrerequisiteGaps()
if (missing.length) {
ElMessage.warning(`安排运输前请先填写:${missing.join('、')}`)
return
}
if (!formData.vehicleId) {
ElMessage.warning('安排运输前请选择车辆')
return
}
}
submitLoading.value = true
try {
const valid = await basicFormRef.value?.validate().catch(() => false)
if (!valid || !validateBusinessRules()) return
if (mode === 'saveAndArrange' || mode === 'rearrange') {
const missing = getArrangePrerequisiteGaps()
if (missing.length) {
ElMessage.warning(`安排运输前请先填写:${missing.join('、')}`)
return
}
if (!formData.vehicleId) {
ElMessage.warning('安排运输前请选择车辆')
return
}
}
mirrorPlanProductsFromLoad()
const commonPayload = buildPlanCommonPayload({ allowClearTransport: isEdit.value })
let planId = props.planId || ''
const wasCreate = !isEdit.value
if (isEdit.value) {
if (!props.planId) return
@@ -1741,6 +1734,15 @@
if ((mode === 'saveAndArrange' || mode === 'rearrange') && planId) {
const arranged = await performArrangeAfterSave(planId)
if (!arranged) {
// 计划已落库;关闭新建窗,避免停留在创建态再次点击又生成一张
if (wasCreate) {
ElMessage.warning(
'计划已创建成功,但未能安排运输。请至列表查看;若因危化证未就绪,请先完成【危化品证上传】后再安排。'
)
} else {
ElMessage.warning('计划已保存,但未能安排运输。请稍后在列表中重试安排。')
}
innerVisible.value = false
emit('success', { planId, arranged: false })
}
return
@@ -1771,7 +1773,7 @@
.pl-plan-transport-row--three {
display: grid;
grid-template-columns: max-content minmax(360px, 520px) minmax(280px, 1fr);
grid-template-columns: max-content minmax(240px, 340px) minmax(280px, 1fr);
gap: 12px 16px;
}
@@ -1782,7 +1784,7 @@
.pl-plan-transport-row__driver {
min-width: 0;
max-width: 520px;
max-width: 340px;
}
.pl-plan-transport-row__carrier {
@@ -1798,8 +1800,8 @@
}
.pl-plan-vehicle-with-library__select {
flex: 0 0 140px;
width: 140px;
flex: 0 0 220px;
width: 220px;
}
.pl-plan-carrier-with-library__select {
@@ -2149,12 +2151,22 @@
<style lang="scss">
.el-dialog.pl-plan-form-dialog.dialog-form-layout {
width: 100% !important;
max-width: calc(100vw - 48px);
width: min(2000px, calc(100vw - 32px)) !important;
max-width: min(2000px, calc(100vw - 32px));
height: var(--dialog-max-height, calc(100vh - 40px));
max-height: var(--dialog-max-height, calc(100vh - 40px));
}
.el-dialog.pl-plan-form-dialog.dialog-form-layout .el-dialog__body {
max-height: calc(100vh - 120px);
display: flex;
flex-direction: column;
flex: 1;
min-height: 0;
max-height: none;
}
.el-dialog.pl-plan-form-dialog.dialog-form-layout .pl-plan-form-body {
flex: 1;
min-height: 0;
}
</style>
@@ -109,7 +109,7 @@
>
生成地磅单({{ dibangDirectionLabel }})
</el-checkbox>
<span v-if="isInternal" class="pl-plan-dibang-row__hint">装货客户为内部客户时默认勾选</span>
<span v-if="isInternal" class="pl-plan-dibang-row__hint">本段客户为内部客户时默认勾选</span>
</div>
</el-form-item>
</div>
@@ -11,7 +11,10 @@
formatFeedbackTime(driverFeedback.feedbackTime)
}}</span>
</div>
<p v-if="!hasDriverFeedback" class="pl-plan-form-empty-hint pl-stop-feedback-ticket__empty">
<p
v-if="!hasDriverFeedback && !editableAttachments"
class="pl-plan-form-empty-hint pl-stop-feedback-ticket__empty"
>
暂无司机回传
</p>
<template v-else>
@@ -34,14 +37,17 @@
<div class="pl-stop-feedback-ticket__foot">
<span class="pl-stop-feedback-ticket__lab">附件</span>
<AttachmentUploadField
v-if="driverAttachmentCsv"
v-if="editableAttachments || driverAttachmentCsv"
ref="driverAttachRef"
class="pl-stop-feedback-ticket__attach"
:model-value="driverAttachmentCsv"
disabled
:class="{ 'pl-stop-feedback-ticket__attach--editable': editableAttachments }"
:model-value="driverAttachmentModel"
:disabled="!editableAttachments"
compact
folder="pl/transport/feedback"
accept="image/*,video/*,.pdf"
:limit="15"
@update:model-value="handleDriverAttachmentChange"
/>
<span v-else class="pl-plan-form-empty-hint">—</span>
</div>
@@ -57,7 +63,10 @@
formatFeedbackTime(siteFeedback.feedbackTime)
}}</span>
</div>
<p v-if="!hasSiteFeedback" class="pl-plan-form-empty-hint pl-stop-feedback-ticket__empty">
<p
v-if="!hasSiteFeedback && !editableAttachments"
class="pl-plan-form-empty-hint pl-stop-feedback-ticket__empty"
>
暂无现场回传
</p>
<template v-else>
@@ -111,14 +120,17 @@
<div class="pl-stop-feedback-ticket__foot">
<span class="pl-stop-feedback-ticket__lab">附件</span>
<AttachmentUploadField
v-if="siteAttachmentCsv"
v-if="editableAttachments || siteAttachmentCsv"
ref="siteAttachRef"
class="pl-stop-feedback-ticket__attach"
:model-value="siteAttachmentCsv"
disabled
:class="{ 'pl-stop-feedback-ticket__attach--editable': editableAttachments }"
:model-value="siteAttachmentModel"
:disabled="!editableAttachments"
compact
folder="pl/transport/site-feedback"
accept="image/*,video/*,.pdf"
:limit="15"
@update:model-value="handleSiteAttachmentChange"
/>
<span v-else class="pl-plan-form-empty-hint">—</span>
</div>
@@ -203,7 +215,7 @@
</template>
<script setup lang="ts">
import { computed } from 'vue'
import { computed, ref } from 'vue'
import type { TransportStopFeedback } from '@/api/pl'
import AttachmentUploadField from '@/components/business/attachment-upload-field/index.vue'
import { formatKgToTon } from '@/components/business/db/db-related-view'
@@ -223,6 +235,10 @@
fallbackRemark?: string
/** 无回传数据时也展示卡片空态 */
showWhenEmpty?: boolean
/** 归档弹窗等场景:允许编辑段级回传附件 */
editableAttachments?: boolean
driverAttachmentUrls?: string
siteAttachmentUrls?: string
}>(),
{
stopLabel: '',
@@ -232,10 +248,21 @@
driverFeedback: null,
siteFeedback: null,
fallbackRemark: '',
showWhenEmpty: true
showWhenEmpty: true,
editableAttachments: false,
driverAttachmentUrls: '',
siteAttachmentUrls: ''
}
)
const emit = defineEmits<{
'update:driverAttachmentUrls': [value: string]
'update:siteAttachmentUrls': [value: string]
}>()
const driverAttachRef = ref<InstanceType<typeof AttachmentUploadField> | null>(null)
const siteAttachRef = ref<InstanceType<typeof AttachmentUploadField> | null>(null)
const isInternalCustomer = computed(() => isPlInternalCustomerName(props.customerName))
const showSiteCard = computed(() => isInternalCustomer.value)
@@ -298,6 +325,44 @@
const driverAttachmentCsv = computed(() => (props.driverFeedback?.attachmentUrls || []).join(','))
const siteAttachmentCsv = computed(() => (props.siteFeedback?.attachmentUrls || []).join(','))
const driverAttachmentModel = computed({
get: () =>
props.editableAttachments ? props.driverAttachmentUrls || '' : driverAttachmentCsv.value,
set: (value: string) => {
if (props.editableAttachments) {
emit('update:driverAttachmentUrls', value)
}
}
})
const siteAttachmentModel = computed({
get: () =>
props.editableAttachments ? props.siteAttachmentUrls || '' : siteAttachmentCsv.value,
set: (value: string) => {
if (props.editableAttachments) {
emit('update:siteAttachmentUrls', value)
}
}
})
function handleDriverAttachmentChange(value: string) {
if (props.editableAttachments) {
emit('update:driverAttachmentUrls', value)
}
}
function handleSiteAttachmentChange(value: string) {
if (props.editableAttachments) {
emit('update:siteAttachmentUrls', value)
}
}
function hasAttachmentUploading() {
return Boolean(driverAttachRef.value?.hasUploading?.() || siteAttachRef.value?.hasUploading?.())
}
defineExpose({ hasAttachmentUploading })
function formatFeedbackTime(value?: string) {
return formatDateTime(value) || '—'
}
@@ -618,6 +683,21 @@
}
}
.pl-stop-feedback-ticket__attach--editable {
:deep(.upload-card) {
width: 88px;
height: 66px;
}
:deep(.attachment-item) {
width: 88px;
}
:deep(.attachment-preview) {
height: 66px;
}
}
@media (max-width: 1280px) {
.pl-stop-feedback-cards.is-cols-3 {
grid-template-columns: repeat(2, minmax(0, 1fr));
@@ -165,8 +165,8 @@
<style lang="scss">
.el-dialog.pl-plan-view-dialog.dialog-form-layout {
width: 100% !important;
max-width: calc(100vw - 48px);
width: min(2000px, calc(100vw - 48px)) !important;
max-width: min(2000px, calc(100vw - 48px));
height: var(--dialog-max-height, calc(100vh - 40px));
max-height: var(--dialog-max-height, calc(100vh - 40px));
}
@@ -1234,7 +1234,7 @@
const deliveryViews = computed(() => {
if (plan.value?.deliveries?.length) {
return mapDeliveriesFromApi(plan.value.deliveries, plan.value.load?.customerName).map(
return mapDeliveriesFromApi(plan.value.deliveries).map(
(row, index) => ({
id: plan.value?.deliveries?.[index]?.id,
...row,
@@ -1512,7 +1512,11 @@
money: hasFreight,
long: false
},
{ label: '是否开票', value: hasFreight ? displayHasInvoiceLabel.value : '—', long: false }
{ label: '是否开票', value: hasFreight ? displayHasInvoiceLabel.value : '—', long: false },
{
label: '运费备注',
value: hasFreight ? plan.value?.freightRemark?.trim() || '—' : '—'
}
]
})
@@ -378,15 +378,19 @@
useCommon().refresh()
return
}
// 强制重新加载:先将目标组件从 KeepAlive 缓存中排除
store.addKeepAliveExclude(item)
// 等待 Vue 处理 exclude 变更、清除缓存后再导航
nextTick(() => {
router.push({
// 切换到已打开的 Tab 时强制刷新。
// 说明:仅靠 keepAliveExclude 无效——① openTab 会立刻 removeKeepAliveExclude;
// ② KeepAlive 按组件 name 匹配,多数 views/**/index.vue 与路由 name 不一致。
router
.push({
path: item.path,
query: item.query as LocationQueryRaw
})
})
.then((failure) => {
if (!failure) {
useCommon().refresh()
}
})
}
const closeWorktab = (type: TabCloseType, tabPath: string) => {
+32 -7
View File
@@ -58,6 +58,18 @@ export function formatPlVehiclePlateDisplay(
return plate || trailer
}
/** 下拉选项:主车号(挂车号);无挂车号时仅主车号 */
export function formatPlVehiclePlateOptionLabel(
licensePlate?: string | null,
trailerNo?: string | null
) {
const plate = licensePlate?.trim() || ''
const trailer = trailerNo?.trim() || ''
if (!plate && !trailer) return '—'
if (plate && trailer) return `${plate}(${trailer})`
return plate || trailer
}
export function getPlCarrierStatusLabel(status: string) {
return status === '1' ? '合作中' : '已终止'
}
@@ -354,13 +366,13 @@ export const PL_PLAN_TYPE_TABS: { label: string; name: PlPlanTypeTab }[] = [
]
export const PL_PLAN_LIST_TABS: { label: string; name: PlPlanListTab }[] = [
...PL_PLAN_TYPE_TABS,
{ label: '待安排', name: 'pending_arrange' }
{ label: '待安排', name: 'pending_arrange' },
...PL_PLAN_TYPE_TABS
]
export const PL_PLAN_CERT_TABS: { label: string; name: PlPlanCertTab }[] = [
...PL_PLAN_TYPE_TABS,
{ label: '未上传证书', name: 'cert_incomplete' }
{ label: '未上传证书', name: 'cert_incomplete' },
...PL_PLAN_TYPE_TABS
]
export function plPlanTypeTabToFilter(tab: PlPlanTypeTab): string {
@@ -389,7 +401,11 @@ export function plPlanCertTabToFilters(tab: PlPlanCertTab): {
hazardCertReady?: string
} {
if (tab === 'cert_incomplete') {
return { planType: '', certUploadStatus: 'incomplete', hazardCertReady: '0' }
return {
planType: '',
certUploadStatus: 'incomplete',
hazardCertReady: '0'
}
}
return { planType: plPlanTypeTabToFilter(tab), hazardCertReady: '' }
}
@@ -410,6 +426,11 @@ export const PL_PLAN_FOLLOW_STATUS_OPTIONS = [
{ label: '已取消', value: 'cancelled' }
] as const
/** 运输计划/危化品证等列表:跟进状态默认勾选(不含已取消) */
export const PL_PLAN_DEFAULT_FOLLOW_STATUSES = PL_PLAN_FOLLOW_STATUS_OPTIONS.filter(
(opt) => opt.value !== 'cancelled'
).map((opt) => opt.value)
export function getPlPlanFollowStatusTagType(status?: string) {
const map: Record<string, string> = {
wait_notice: 'warning',
@@ -438,11 +459,15 @@ export function getPlPlanFollowStatusLabel(status?: string) {
}
export function getPlPlanArchiveStatusTagType(status?: string) {
return status === 'archived' ? 'info' : 'danger'
if (status === 'archived') return 'info'
if (status === 'draft') return 'warning'
return 'danger'
}
export function getPlPlanArchiveStatusLabel(status?: string) {
return status === 'archived' ? '已归档' : '未归档'
if (status === 'archived') return '已归档'
if (status === 'draft') return '已暂存'
return '未归档'
}
export function getPlPlanCompleteStatusLabel(status?: string) {
+41 -31
View File
@@ -111,12 +111,12 @@ export interface PlanDeliveryForm {
products: PlanStopProductFormRow[]
}
/** 地磅默认勾选以装货客户是否为内部客户(山峡/云栋)为准,与送货段客户无关。 */
/** 地磅默认勾选以本段客户是否为内部客户(山峡/云栋)为准。 */
export function resolveStopDibangDefaults(
loadCustomerName?: string | null,
customerName?: string | null,
stopType: 'load' | 'delivery' = 'load'
): { generateDibang: number; dibangDirection: string } {
if (!isPlInternalCustomerName(loadCustomerName)) {
if (!isPlInternalCustomerName(customerName)) {
return { generateDibang: 0, dibangDirection: 'none' }
}
if (stopType === 'load') {
@@ -125,16 +125,23 @@ export function resolveStopDibangDefaults(
return { generateDibang: 1, dibangDirection: 'inbound' }
}
export function syncDeliveryDibangFromLoad(
deliveries: PlanDeliveryForm[],
loadCustomerName?: string | null
): PlanDeliveryForm[] {
const defaults = resolveStopDibangDefaults(loadCustomerName, 'delivery')
return deliveries.map((row) => ({
...row,
generateDibang: defaults.generateDibang,
dibangDirection: defaults.dibangDirection
}))
function normalizeStopDibangFieldsFromApi(
customerName: string | null | undefined,
stopType: 'load' | 'delivery',
generateDibang?: number | null,
dibangDirection?: string | null
): { generateDibang: number; dibangDirection: string } {
const defaults = resolveStopDibangDefaults(customerName, stopType)
const gen = Number(generateDibang ?? defaults.generateDibang) === 1 ? 1 : 0
let direction = (dibangDirection || '').trim()
if (gen) {
if (direction !== 'outbound' && direction !== 'inbound') {
direction = defaults.dibangDirection
}
} else {
direction = 'none'
}
return { generateDibang: gen, dibangDirection: direction }
}
export function createStopProductsFromPlanProducts(
@@ -323,11 +330,7 @@ export function createEmptyLoadForm(): PlanLoadForm {
}
}
export function createEmptyDeliveryForm(
seq = 1,
loadCustomerName?: string | null
): PlanDeliveryForm {
const defaults = resolveStopDibangDefaults(loadCustomerName, 'delivery')
export function createEmptyDeliveryForm(seq = 1): PlanDeliveryForm {
return {
seq,
customerId: '',
@@ -338,8 +341,8 @@ export function createEmptyDeliveryForm(
deliveryTime: '',
contact: '',
notes: '',
generateDibang: defaults.generateDibang,
dibangDirection: defaults.dibangDirection,
generateDibang: 0,
dibangDirection: 'none',
contracts: [],
products: []
}
@@ -404,7 +407,12 @@ export function resolveDeliveryViewAddress(
export function mapLoadFromApi(load?: PlanLoad | null): PlanLoadForm {
if (!load) return createEmptyLoadForm()
const defaults = resolveStopDibangDefaults(load.customerName, 'load')
const dibang = normalizeStopDibangFieldsFromApi(
load.customerName,
'load',
load.generateDibang,
load.dibangDirection
)
return {
customerId: load.customerId || '',
customerName: load.customerName || '',
@@ -414,8 +422,8 @@ export function mapLoadFromApi(load?: PlanLoad | null): PlanLoadForm {
loadTime: (load.loadTime || '').slice(0, 10),
contact: load.contact || '',
notes: load.notes || '',
generateDibang: load.generateDibang ?? defaults.generateDibang,
dibangDirection: load.dibangDirection || defaults.dibangDirection,
generateDibang: dibang.generateDibang,
dibangDirection: dibang.dibangDirection,
contracts: (load.contracts || []).map((item) => ({
contractId: String(item.contractId || ''),
contractNo: item.contractNo
@@ -424,13 +432,15 @@ export function mapLoadFromApi(load?: PlanLoad | null): PlanLoadForm {
}
}
export function mapDeliveriesFromApi(
deliveries?: PlanDelivery[],
loadCustomerName?: string | null
): PlanDeliveryForm[] {
export function mapDeliveriesFromApi(deliveries?: PlanDelivery[]): PlanDeliveryForm[] {
if (!deliveries?.length) return [createEmptyDeliveryForm(1)]
return deliveries.map((row, index) => {
const defaults = resolveStopDibangDefaults(loadCustomerName, 'delivery')
const dibang = normalizeStopDibangFieldsFromApi(
row.customerName,
'delivery',
row.generateDibang,
row.dibangDirection
)
return {
seq: row.seq ?? index + 1,
customerId: row.customerId || '',
@@ -441,8 +451,8 @@ export function mapDeliveriesFromApi(
deliveryTime: (row.deliveryTime || '').slice(0, 10),
contact: row.contact || '',
notes: row.notes || '',
generateDibang: row.generateDibang ?? defaults.generateDibang,
dibangDirection: row.dibangDirection || defaults.dibangDirection,
generateDibang: dibang.generateDibang,
dibangDirection: dibang.dibangDirection,
contracts: (row.contracts || []).map((item) => ({
contractId: String(item.contractId || ''),
contractNo: item.contractNo
@@ -458,7 +468,7 @@ export function mapLegacyPlanToStops(plan: Plan): {
deliveries: PlanDeliveryForm[]
} {
const loadDefaults = resolveStopDibangDefaults(plan.supplierName, 'load')
const deliveryDefaults = resolveStopDibangDefaults(plan.supplierName, 'delivery')
const deliveryDefaults = resolveStopDibangDefaults(plan.customerName, 'delivery')
const stopProducts = createStopProductsFromPlanProducts(
(plan.products || []).map((item, index) => ({
id: item.id,
@@ -484,6 +484,7 @@
<DbInventoryRelatedViewDialog
v-model:visible="relatedModalOpen"
:loading="loadingRelated"
:inventory="viewingRecord"
:data="relatedData"
>
<template v-if="viewingRecord" #hero-actions>
+1
View File
@@ -447,6 +447,7 @@
<DbPlanRelatedViewDialog
v-model:visible="relatedModalOpen"
:loading="loadingRelated"
:plan="viewingRecord"
:data="relatedData"
>
<template v-if="viewingRecord" #hero-actions>
+3 -1
View File
@@ -684,7 +684,9 @@
relatedData.value = await weighingApi.getRelated(viewingRecord.value.id)
}
const relatedViewSections = computed(() => buildWeighingRelatedSections(relatedData.value))
const relatedViewSections = computed(() =>
buildWeighingRelatedSections(relatedData.value, viewingRecord.value)
)
const formRef = ref()
const formData = reactive<
+3 -32
View File
@@ -54,6 +54,7 @@
<el-form-item label="归档状态">
<el-select v-model="searchForm.archiveStatus" placeholder="全部" clearable>
<el-option label="未归档" value="unarchived" />
<el-option label="已暂存" value="draft" />
<el-option label="已归档" value="archived" />
</el-select>
</el-form-item>
@@ -222,7 +223,7 @@
<el-table-column
v-if="isColumnVisible('documentAttachments')"
label="单据附件"
min-width="220"
min-width="280"
align="left"
header-align="left"
>
@@ -611,10 +612,6 @@ import {
Search
} from '@element-plus/icons-vue'
import { planApi, type Plan } from '@/api/pl'
import {
buildMissingHazardCertReadyMessage,
enrichPlanProductsHazardFromCrm
} from '@/composables/usePlToxicProductCertCheck'
import { pickBxData } from '@/utils/http/bx'
import PlPlanContractCell from '@/components/business/pl-plan-contract-cell/index.vue'
import PlPlanArchiveDialog from '@/components/business/pl-plan-archive-dialog/index.vue'
@@ -967,33 +964,7 @@ function archiveButtonLabel(row: Plan) {
}
async function handleArchive(row: Plan) {
if (row.archiveStatus === 'archived') {
archivePlanId.value = row.id
archiveDialogVisible.value = true
return
}
try {
const res = await planApi.get(row.id)
const data = pickBxData<Plan>(res)
if (!data?.id) {
throw new Error('运输计划数据无效')
}
const rawProducts = Array.isArray(data.products) ? data.products : []
const enrichedProducts = await enrichPlanProductsHazardFromCrm(rawProducts)
const certMessage = buildMissingHazardCertReadyMessage(data, enrichedProducts)
if (certMessage) {
await ElMessageBox.alert(`${certMessage},请至【危化品证上传】页面操作。`, '无法归档', {
type: 'warning'
})
return
}
} catch (error) {
const message = error instanceof Error ? error.message : '加载运输计划失败'
ElMessage.error(message.includes('加载') ? message : `加载运输计划失败:${message}`)
return
}
// 打开归档弹窗:已归档走调整;未归档/已暂存可直接打开(证书齐备仅在「确认归档」时校验,以便支持暂存)
archivePlanId.value = row.id
archiveDialogVisible.value = true
}
+28 -16
View File
@@ -21,7 +21,12 @@
/>
</el-form-item>
<el-form-item label="跟进状态">
<el-select v-model="searchForm.followStatus" placeholder="全部" clearable>
<el-select
v-model="searchForm.followStatus"
placeholder="全部"
clearable
multiple
>
<el-option
v-for="opt in PL_PLAN_FOLLOW_STATUS_OPTIONS"
:key="opt.value"
@@ -543,6 +548,7 @@
getPlPlanFollowStatusLabel,
getPlPlanFollowStatusTagType,
normalizePlPersonnelSummaryDisplay,
PL_PLAN_DEFAULT_FOLLOW_STATUSES,
PL_PLAN_CERT_TABS,
PL_PLAN_FOLLOW_STATUS_OPTIONS,
PL_PLAN_HAZARD_CERT_READY_FILTER_OPTIONS,
@@ -644,7 +650,7 @@
q: keyword || undefined,
planNo: keyword ? undefined : searchForm.planNo || undefined,
planType: searchForm.planType || undefined,
followStatus: searchForm.followStatus || undefined,
followStatus: formatFollowStatusParam(searchForm.followStatus),
customerName: keyword ? undefined : searchForm.customerName || undefined,
planDateFrom: dateRange.value?.[0] || undefined,
planDateTo: dateRange.value?.[1] || undefined,
@@ -668,17 +674,28 @@
)
const dateRange = ref<string[]>([])
const quickSearch = ref('')
const activePlanTypeTab = ref<PlPlanCertTab>('all')
const activePlanTypeTab = ref<PlPlanCertTab>('cert_incomplete')
const searchForm = reactive({
planNo: '',
planType: '',
followStatus: '',
followStatus: [...PL_PLAN_DEFAULT_FOLLOW_STATUSES] as string[],
customerName: '',
certUploadStatus: '' as string,
hazardCertReady: '' as string
certUploadStatus: 'incomplete' as string,
hazardCertReady: '0' as string
})
function formatFollowStatusParam(statuses: string[]) {
return statuses.length ? statuses.join(',') : undefined
}
function applyPlanTypeTabFilters(tab: PlPlanCertTab) {
const filters = plPlanCertTabToFilters(tab)
searchForm.planType = filters.planType
searchForm.certUploadStatus = filters.certUploadStatus || ''
searchForm.hazardCertReady = filters.hazardCertReady ?? ''
}
function getPlanTypeLabel(type: string) {
const map: Record<string, string> = { direct: '直销单', inbound: '入库单', outbound: '出库单' }
return map[type] || type
@@ -692,7 +709,7 @@
q: keyword || undefined,
planNo: keyword ? undefined : searchForm.planNo || undefined,
planType: searchForm.planType || undefined,
followStatus: searchForm.followStatus || undefined,
followStatus: formatFollowStatusParam(searchForm.followStatus),
customerName: keyword ? undefined : searchForm.customerName || undefined,
planDateFrom: dateRange.value?.[0] || undefined,
planDateTo: dateRange.value?.[1] || undefined,
@@ -717,22 +734,17 @@
}
function handlePlanTypeTabChange(tab: PlPlanCertTab | string) {
const filters = plPlanCertTabToFilters(tab as PlPlanCertTab)
searchForm.planType = filters.planType
searchForm.certUploadStatus = filters.certUploadStatus || ''
searchForm.hazardCertReady = filters.hazardCertReady ?? ''
applyPlanTypeTabFilters(tab as PlPlanCertTab)
pagination.page = 1
fetchData()
}
function handleReset() {
activePlanTypeTab.value = 'all'
activePlanTypeTab.value = 'cert_incomplete'
searchForm.planNo = ''
searchForm.planType = ''
searchForm.followStatus = ''
searchForm.followStatus = [...PL_PLAN_DEFAULT_FOLLOW_STATUSES]
searchForm.customerName = ''
searchForm.certUploadStatus = ''
searchForm.hazardCertReady = ''
applyPlanTypeTabFilters('cert_incomplete')
quickSearch.value = ''
resetDateShortcut()
pagination.page = 1
@@ -345,7 +345,7 @@
v-model="supplementVisible"
class="dialog-form-layout pl-contract-supplement-dialog"
modal-class="order-module-dialog-mask"
width="960px"
width="min(2000px, calc(100vw - 48px))"
align-center
destroy-on-close
:close-on-click-modal="false"
+44 -35
View File
@@ -25,6 +25,7 @@
v-model="searchForm.followStatus"
placeholder="全部"
clearable
multiple
:disabled="activePlanTypeTab === 'pending_arrange'"
>
<el-option
@@ -291,10 +292,10 @@
</el-table-column>
<el-table-column
v-if="isColumnVisible('arrangeCopy')"
label="复制"
min-width="168"
align="left"
header-align="left"
label="链接复制"
min-width="88"
align="center"
header-align="center"
>
<template #default="{ row }">
<div
@@ -305,35 +306,38 @@
"
class="pl-plan-arrange-copy-cell"
>
<el-button
v-if="row.plan.canCopyToDriver"
class="btn-ghost"
:loading="
arrangeCopyLoadingId === row.plan.id && arrangeCopyLoadingAction === 'driver'
"
@click.stop="handleListCopyDriver(row.plan)"
>
<el-icon><CopyDocument /></el-icon>复制给司机
</el-button>
<el-button
v-if="row.plan.canCopyToSite"
class="btn-ghost"
:loading="
arrangeCopyLoadingId === row.plan.id && arrangeCopyLoadingAction === 'site'
"
@click.stop="handleListCopySite(row.plan)"
>
<el-icon><CopyDocument /></el-icon>复制给现场
</el-button>
<el-button
v-if="row.plan.canCopyPoundQrcode"
class="btn-ghost"
title="复制磅单二维码"
:loading="
arrangeCopyLoadingId === row.plan.id && arrangeCopyLoadingAction === 'qrcode'
"
@click.stop="handleListCopyPoundQrcode(row.plan)"
>
<el-icon><CopyDocument /></el-icon>复制磅单二维码
磅单码
</el-button>
<el-button
v-if="row.plan.canCopyToDriver"
class="btn-ghost"
title="复制给司机"
:loading="
arrangeCopyLoadingId === row.plan.id && arrangeCopyLoadingAction === 'driver'
"
@click.stop="handleListCopyDriver(row.plan)"
>
司机
</el-button>
<el-button
v-if="row.plan.canCopyToSite"
class="btn-ghost"
title="复制给现场"
:loading="
arrangeCopyLoadingId === row.plan.id && arrangeCopyLoadingAction === 'site'
"
@click.stop="handleListCopySite(row.plan)"
>
现场
</el-button>
</div>
<span v-else>—</span>
@@ -835,6 +839,7 @@
getPlPlanFollowStatusLabel,
getPlPlanFollowStatusTagType,
normalizePlPersonnelSummaryDisplay,
PL_PLAN_DEFAULT_FOLLOW_STATUSES,
PL_PLAN_FOLLOW_STATUS_OPTIONS,
PL_PLAN_LIST_TABS,
plPlanListTabToFilters,
@@ -885,7 +890,7 @@
{ prop: 'licensePlate', label: '车牌号' },
{ prop: 'personnelSummary', label: '人员' },
{ prop: 'followUserName', label: '跟进人', defaultVisible: false },
{ prop: 'arrangeCopy', label: '复制' },
{ prop: 'arrangeCopy', label: '链接复制' },
{ prop: 'stopKind', label: '段次' },
{ prop: 'stopCustomer', label: '客户' },
{ prop: 'stopAddressTime', label: '地址 / 时间' },
@@ -1079,7 +1084,7 @@
q: keyword || undefined,
planNo: keyword ? undefined : searchForm.planNo || undefined,
planType: tabFilters.planType || undefined,
followStatus: tabFilters.followStatus || searchForm.followStatus || undefined,
followStatus: tabFilters.followStatus || formatFollowStatusParam(searchForm.followStatus),
customerName: keyword ? undefined : searchForm.customerName || undefined,
productName: keyword ? undefined : searchForm.productName || undefined,
licensePlate: keyword ? undefined : searchForm.licensePlate || undefined,
@@ -1182,12 +1187,12 @@
)
const dateRange = ref<string[]>([])
const quickSearch = ref('')
const activePlanTypeTab = ref<PlPlanListTab>('all')
const activePlanTypeTab = ref<PlPlanListTab>('pending_arrange')
const searchForm = reactive({
planNo: '',
planType: '',
followStatus: '',
followStatus: ['pending_arrange'] as string[],
customerName: '',
productName: '',
licensePlate: ''
@@ -1199,6 +1204,10 @@
total: 0
})
function formatFollowStatusParam(statuses: string[]) {
return statuses.length ? statuses.join(',') : undefined
}
function getPlanTypeLabel(type?: string | null) {
if (!type) return '—'
const map: Record<string, string> = { direct: '直销单', inbound: '入库单', outbound: '出库单' }
@@ -1214,7 +1223,7 @@
q: keyword || undefined,
planNo: keyword ? undefined : searchForm.planNo || undefined,
planType: tabFilters.planType || undefined,
followStatus: tabFilters.followStatus || searchForm.followStatus || undefined,
followStatus: tabFilters.followStatus || formatFollowStatusParam(searchForm.followStatus),
customerName: keyword ? undefined : searchForm.customerName || undefined,
productName: keyword ? undefined : searchForm.productName || undefined,
licensePlate: keyword ? undefined : searchForm.licensePlate || undefined,
@@ -1243,19 +1252,19 @@
const filters = plPlanListTabToFilters(nextTab)
searchForm.planType = filters.planType
if (nextTab === 'pending_arrange') {
searchForm.followStatus = 'pending_arrange'
searchForm.followStatus = ['pending_arrange']
} else if (prevTab === 'pending_arrange') {
searchForm.followStatus = ''
searchForm.followStatus = [...PL_PLAN_DEFAULT_FOLLOW_STATUSES]
}
pagination.page = 1
fetchData()
}
function handleReset() {
activePlanTypeTab.value = 'all'
activePlanTypeTab.value = 'pending_arrange'
searchForm.planNo = ''
searchForm.planType = ''
searchForm.followStatus = ''
searchForm.followStatus = ['pending_arrange']
searchForm.customerName = ''
searchForm.productName = ''
searchForm.licensePlate = ''
@@ -1660,7 +1669,7 @@
.pl-plan-arrange-copy-cell {
display: flex;
flex-direction: column;
align-items: flex-start;
align-items: center;
gap: 8px;
width: 100%;
}