提交
This commit is contained in:
1 parent
e56d227fe8
commit
4611dbc2b2
237 files changed
+1384060
-24942
No files matched your search
+225
-28
@@ -1,6 +1,7 @@
|
||||
/**
|
||||
* 运输计划管理 API
|
||||
*/
|
||||
import { ElMessage } from 'element-plus'
|
||||
import request from '@/utils/http/bx'
|
||||
import { pickBxList, pickBxPageResult } from '@/utils/http/bx'
|
||||
import type { TransportResourceSnapshot } from '@/utils/pl-transport-resource-snapshot'
|
||||
@@ -50,7 +51,8 @@ export const carrierApi = {
|
||||
request.post('/transport/carrier/export', data, { responseType: 'blob' }),
|
||||
get: (id: string) => request.get<Carrier>(`/transport/carrier/${id}`),
|
||||
create: (data: Partial<Carrier>) => request.post<Carrier>('/transport/carrier', data),
|
||||
update: (id: string, data: Partial<Carrier>) => request.put<Carrier>(`/transport/carrier/${id}`, data),
|
||||
update: (id: string, data: Partial<Carrier>) =>
|
||||
request.put<Carrier>(`/transport/carrier/${id}`, data),
|
||||
/** @deprecated 承运商审核已移除,后端接口已禁用 */
|
||||
approve: (id: string) => request.post<Carrier>(`/transport/carrier/${id}/approve`),
|
||||
reject: (id: string, data?: { remark?: string }) =>
|
||||
@@ -310,6 +312,23 @@ export const transportAddressApi = {
|
||||
delete: (id: string) => request.delete(`/transport/address/${id}`)
|
||||
}
|
||||
|
||||
export type CustomerStopPrefStopType = 'load' | 'delivery'
|
||||
|
||||
export interface CustomerStopPref {
|
||||
customerId: string
|
||||
stopType: CustomerStopPrefStopType
|
||||
address?: string
|
||||
lng?: number | null
|
||||
lat?: number | null
|
||||
contact?: string
|
||||
notes?: string
|
||||
}
|
||||
|
||||
export const customerStopPrefApi = {
|
||||
get: (params: { customerId: string; stopType: CustomerStopPrefStopType }) =>
|
||||
request.get<CustomerStopPref | null>('/transport/customer-stop-pref', { params })
|
||||
}
|
||||
|
||||
// 司机(兼容旧 API,映射至 personnel)
|
||||
export interface Driver {
|
||||
id: string
|
||||
@@ -401,6 +420,68 @@ export interface PlanDocumentAttachmentItem {
|
||||
export interface PlanContractLink {
|
||||
contractId: string
|
||||
contractNo?: string
|
||||
stopId?: string
|
||||
}
|
||||
|
||||
/** 装货/送货段产品行 */
|
||||
export interface PlanStopProduct {
|
||||
id?: string
|
||||
planProductId?: string
|
||||
productId: string
|
||||
productNo: string
|
||||
productName: string
|
||||
model?: string
|
||||
unit: string
|
||||
packageSpec?: string
|
||||
deliveryMethod?: string
|
||||
planQty?: number
|
||||
inboundQty?: number
|
||||
inboundPrice?: number
|
||||
inboundAmount?: number
|
||||
outboundQty?: number
|
||||
outboundPrice?: number
|
||||
outboundAmount?: number
|
||||
remark?: string
|
||||
}
|
||||
|
||||
/** 装货段(计划 1:1) */
|
||||
export interface PlanLoad {
|
||||
id?: string
|
||||
planId?: string
|
||||
customerId?: string
|
||||
customerName?: string
|
||||
address?: string
|
||||
lng?: number | null
|
||||
lat?: number | null
|
||||
loadTime?: string
|
||||
contact?: string
|
||||
notes?: string
|
||||
generateDibang?: number
|
||||
dibangDirection?: string
|
||||
remark?: string
|
||||
products?: PlanStopProduct[]
|
||||
contracts?: PlanContractLink[]
|
||||
}
|
||||
|
||||
/** 送货段(计划 1:N) */
|
||||
export interface PlanDelivery {
|
||||
id?: string
|
||||
planId?: string
|
||||
seq?: number
|
||||
customerId?: string
|
||||
customerName?: string
|
||||
address?: string
|
||||
lng?: number | null
|
||||
lat?: number | null
|
||||
deliveryTime?: string
|
||||
contact?: string
|
||||
notes?: string
|
||||
generateDibang?: number
|
||||
dibangDirection?: string
|
||||
remark?: string
|
||||
deliveryMethod?: string
|
||||
products?: PlanStopProduct[]
|
||||
contracts?: PlanContractLink[]
|
||||
}
|
||||
|
||||
export interface PlanProduct {
|
||||
@@ -494,6 +575,7 @@ export interface Plan {
|
||||
transportNo?: string
|
||||
totalAmount: number
|
||||
freightAmount: number
|
||||
freightRemark?: string
|
||||
notifyMessage?: string
|
||||
followUserId?: string
|
||||
followUserName?: string
|
||||
@@ -505,8 +587,6 @@ export interface Plan {
|
||||
createBy?: string
|
||||
createTime: string
|
||||
products?: PlanProduct[]
|
||||
supplierContracts?: PlanContractLink[]
|
||||
demanderContracts?: PlanContractLink[]
|
||||
/** 列表:是否显示「复制给司机」 */
|
||||
canCopyToDriver?: boolean
|
||||
/** 列表:是否显示「复制给现场」 */
|
||||
@@ -515,6 +595,16 @@ export interface Plan {
|
||||
canCopyPoundQrcode?: boolean
|
||||
/** 列表:单据附件(司机/现场/出入库现场等) */
|
||||
documentAttachments?: PlanDocumentAttachmentItem[]
|
||||
/** 装货段 */
|
||||
load?: PlanLoad | null
|
||||
/** 送货段列表 */
|
||||
deliveries?: PlanDelivery[]
|
||||
/** 列表:装货客户名称 */
|
||||
loadCustomerName?: string
|
||||
/** 列表:送货客户摘要 */
|
||||
deliveryCustomerSummary?: string
|
||||
/** 保存告警(如数量不平衡,HTTP 200 仍返回) */
|
||||
warnings?: string[]
|
||||
}
|
||||
|
||||
export interface PlanQuery {
|
||||
@@ -577,6 +667,7 @@ export interface PlanCreateFullPayload {
|
||||
deliveryMethod?: string
|
||||
settlementMethod?: string
|
||||
hasFreight: number
|
||||
freightRemark?: string
|
||||
pickupAddress?: string
|
||||
pickupLng?: number | null
|
||||
pickupLat?: number | null
|
||||
@@ -594,6 +685,8 @@ export interface PlanCreateFullPayload {
|
||||
remark?: string
|
||||
supplierContracts?: PlanContractLink[]
|
||||
demanderContracts?: PlanContractLink[]
|
||||
load?: PlanLoad
|
||||
deliveries?: PlanDelivery[]
|
||||
products: Array<{
|
||||
productId: string
|
||||
productNo: string
|
||||
@@ -617,6 +710,19 @@ export interface PlanCreateFullPayload {
|
||||
|
||||
export type PlanUpdatePayload = Partial<Omit<PlanCreateFullPayload, 'contractId'>>
|
||||
|
||||
/** 展示计划保存返回的告警(数量不平衡等) */
|
||||
export function showPlanSaveWarnings(plan?: Pick<Plan, 'warnings'> | null) {
|
||||
const warnings = plan?.warnings
|
||||
if (!warnings?.length) return
|
||||
const seen = new Set<string>()
|
||||
for (const msg of warnings) {
|
||||
const text = (msg || '').trim()
|
||||
if (!text || seen.has(text)) continue
|
||||
seen.add(text)
|
||||
ElMessage.warning(text)
|
||||
}
|
||||
}
|
||||
|
||||
export interface PlanArchiveBrandQtyItem {
|
||||
brandId: string
|
||||
brandName?: string
|
||||
@@ -648,8 +754,27 @@ export interface PlanArchiveProductItem {
|
||||
brandQtys?: PlanArchiveBrandQtyItem[]
|
||||
}
|
||||
|
||||
export interface PlanArchiveStopProductItem {
|
||||
id: string
|
||||
inboundQty?: number
|
||||
inboundPrice?: number
|
||||
outboundQty?: number
|
||||
outboundPrice?: number
|
||||
}
|
||||
|
||||
export interface PlanArchiveLoadBlock {
|
||||
stopId: string
|
||||
products: PlanArchiveStopProductItem[]
|
||||
}
|
||||
|
||||
export interface PlanArchiveDeliveryBlock {
|
||||
stopId: string
|
||||
products: PlanArchiveStopProductItem[]
|
||||
}
|
||||
|
||||
export interface PlanArchiveFreightBlock {
|
||||
hasFreight: number
|
||||
freightRemark?: string
|
||||
distanceKm?: number
|
||||
freightType?: string
|
||||
freightPrice?: number
|
||||
@@ -659,7 +784,9 @@ export interface PlanArchiveFreightBlock {
|
||||
}
|
||||
|
||||
export interface PlanArchiveBody {
|
||||
products: PlanArchiveProductItem[]
|
||||
products?: PlanArchiveProductItem[]
|
||||
load?: PlanArchiveLoadBlock
|
||||
deliveries?: PlanArchiveDeliveryBlock[]
|
||||
freight?: PlanArchiveFreightBlock
|
||||
}
|
||||
|
||||
@@ -722,7 +849,8 @@ export const planApi = {
|
||||
params: { contractIds: contractIds.join(',') }
|
||||
}),
|
||||
create: (data: Partial<Plan>) => request.post<Plan>('/transport/plan/', data),
|
||||
createFull: (data: PlanCreateFullPayload) => request.post<Plan>('/transport/plan/create-full', data),
|
||||
createFull: (data: PlanCreateFullPayload) =>
|
||||
request.post<Plan>('/transport/plan/create-full', data),
|
||||
update: (id: string, data: PlanUpdatePayload) => request.put<Plan>(`/transport/plan/${id}`, data),
|
||||
updateProductCerts: (
|
||||
id: string,
|
||||
@@ -739,11 +867,11 @@ export const planApi = {
|
||||
request.patch<Plan>(`/transport/plan/${id}/erp-entered`, { entered }),
|
||||
cancel: (id: string) => request.post<Plan>(`/transport/plan/${id}/cancel`),
|
||||
waitNotice: (id: string) => request.post<Plan>(`/transport/plan/${id}/wait-notice`),
|
||||
cancelWaitNotice: (id: string) =>
|
||||
request.post<Plan>(`/transport/plan/${id}/cancel-wait-notice`),
|
||||
cancelWaitNotice: (id: string) => request.post<Plan>(`/transport/plan/${id}/cancel-wait-notice`),
|
||||
forceFollowStatus: (id: string, followStatus: string) =>
|
||||
request.post<Plan>(`/transport/plan/${id}/force-follow-status`, { followStatus }),
|
||||
getArrangeInfo: (id: string) => request.get<PlanArrangeInfo>(`/transport/plan/${id}/arrange-info`),
|
||||
getArrangeInfo: (id: string) =>
|
||||
request.get<PlanArrangeInfo>(`/transport/plan/${id}/arrange-info`),
|
||||
archive: (id: string, data?: PlanArchiveBody) =>
|
||||
request.post<Plan>(`/transport/plan/${id}/archive`, data),
|
||||
updateDriverFeedback: (id: string, data: PlanDriverFeedbackUpdateBody) =>
|
||||
@@ -757,8 +885,7 @@ export const planApi = {
|
||||
createDate?: string
|
||||
followUserId?: string
|
||||
followUserName?: string
|
||||
}) =>
|
||||
request.post<Plan>('/transport/plan/create-from-contract', data),
|
||||
}) => request.post<Plan>('/transport/plan/create-from-contract', data),
|
||||
getInboundSlipTemplate: (id: string) =>
|
||||
request.get<string>(`/transport/plan/${id}/inbound-slip-template`),
|
||||
saveInboundSlipTemplate: (id: string, slipTemplateContent: string) =>
|
||||
@@ -767,6 +894,20 @@ export const planApi = {
|
||||
request.get<string>(`/transport/plan/${id}/delivery-slip-template`),
|
||||
saveDeliverySlipTemplate: (id: string, slipTemplateContent: string) =>
|
||||
request.put(`/transport/plan/${id}/delivery-slip-template`, { slipTemplateContent }),
|
||||
getPrintDeliverySlip: (id: string, customerId?: string) =>
|
||||
request.get<{
|
||||
planId: string
|
||||
planNo: string
|
||||
planDate?: string
|
||||
customerId?: string
|
||||
receivingUnit?: string
|
||||
receiveContact?: string
|
||||
deliveryAddress?: string
|
||||
products?: PlanStopProduct[]
|
||||
customers?: { customerId: string; customerName: string; deliveryCount: number }[]
|
||||
}>(`/transport/plan/${id}/print-delivery-slip`, {
|
||||
params: customerId ? { customerId } : undefined
|
||||
}),
|
||||
getSubpackSlipTemplate: (id: string) =>
|
||||
request.get<string>(`/transport/plan/${id}/subpack-slip-template`),
|
||||
saveSubpackSlipTemplate: (id: string, slipTemplateContent: string) =>
|
||||
@@ -777,11 +918,7 @@ export const planApi = {
|
||||
request.get<PlListResponse<PlanContractGapItem>>('/transport/plan/contract-gaps', { params }),
|
||||
exportContractGaps: (data: Record<string, any>) =>
|
||||
request.post('/transport/plan/contract-gaps/export', data, { responseType: 'blob' }),
|
||||
updateSideContracts: (
|
||||
id: string,
|
||||
side: 'supplier' | 'demander',
|
||||
contracts: PlanContractLink[]
|
||||
) =>
|
||||
updateSideContracts: (id: string, side: 'supplier' | 'demander', contracts: PlanContractLink[]) =>
|
||||
request.put<PlanContractGapItem>(`/transport/plan/${id}/contracts/${side}`, { contracts })
|
||||
}
|
||||
|
||||
@@ -789,6 +926,29 @@ export const planApi = {
|
||||
// 运输管理 API
|
||||
// =============================================================================
|
||||
|
||||
export interface TransportStopFeedback {
|
||||
stopType: 'load' | 'delivery'
|
||||
stopId: string
|
||||
label: string
|
||||
customerName: string
|
||||
businessType?: string
|
||||
quantity?: number
|
||||
attachmentUrls?: string[]
|
||||
products?: {
|
||||
stopProductId: string
|
||||
planProductId?: string
|
||||
productName?: string
|
||||
model?: string
|
||||
unit?: string
|
||||
packageSpec?: string
|
||||
quantity?: number
|
||||
actualQty?: number
|
||||
brandQtys?: { brandId: string; brandName?: string; qty: number }[]
|
||||
}[]
|
||||
remark?: string
|
||||
feedbackTime?: string
|
||||
}
|
||||
|
||||
export interface Transport {
|
||||
id: string
|
||||
transportNo: string
|
||||
@@ -820,10 +980,18 @@ export interface Transport {
|
||||
feedbackImages?: string
|
||||
feedbackRemark?: string
|
||||
driverProductFeedbacks?: TransportDriverProductFeedback[]
|
||||
driverStopFeedbacks?: TransportStopFeedback[]
|
||||
siteStopFeedbacks?: TransportStopFeedback[]
|
||||
remark?: string
|
||||
createTime: string
|
||||
}
|
||||
|
||||
export interface TransportStopDibangOption {
|
||||
stopType: 'load' | 'delivery'
|
||||
stopId: string
|
||||
generateDibang: boolean
|
||||
}
|
||||
|
||||
export interface TransportArrange {
|
||||
vehicleId: string
|
||||
driverId?: string
|
||||
@@ -849,6 +1017,7 @@ export interface TransportArrange {
|
||||
hasInvoice?: number
|
||||
remark?: string
|
||||
generateDibangPlan?: boolean
|
||||
stopDibangOptions?: TransportStopDibangOption[]
|
||||
}
|
||||
|
||||
export interface TransportInventoryLink {
|
||||
@@ -858,6 +1027,8 @@ export interface TransportInventoryLink {
|
||||
dbInventoryId: string
|
||||
batchNo: string
|
||||
planNo: string
|
||||
stopType?: 'load' | 'delivery'
|
||||
stopId?: string
|
||||
}
|
||||
|
||||
export interface TransportSiteLink {
|
||||
@@ -883,6 +1054,7 @@ export interface TransportIoOrderBrief {
|
||||
}
|
||||
|
||||
export interface PlanArrangeInfo {
|
||||
requiresSiteLink?: boolean
|
||||
driverUrl?: string
|
||||
licensePlate?: string
|
||||
siteRecords?: TransportSiteLink[]
|
||||
@@ -1029,7 +1201,8 @@ export interface TransportListResponse {
|
||||
}
|
||||
|
||||
export const transportApi = {
|
||||
list: (params?: TransportQuery) => request.get<TransportListResponse>('/transport/order/', { params }),
|
||||
list: (params?: TransportQuery) =>
|
||||
request.get<TransportListResponse>('/transport/order/', { params }),
|
||||
export: (data: Record<string, any>) =>
|
||||
request.post('/transport/order/export', data, { responseType: 'blob' }),
|
||||
get: (id: string) => request.get<Transport>(`/transport/order/${id}`),
|
||||
@@ -1044,8 +1217,13 @@ export const transportApi = {
|
||||
),
|
||||
submitApproval: (id: string, approverIds: string[]) =>
|
||||
request.post<Transport>(`/transport/order/${id}/submit-approval`, { approverIds }),
|
||||
scanFeedback: (data: { transportNo: string; verifyCode?: string; feedbackQty?: number; feedbackImages?: string[]; feedbackRemark?: string }) =>
|
||||
request.post('/transport/order/scan/feedback', data),
|
||||
scanFeedback: (data: {
|
||||
transportNo: string
|
||||
verifyCode?: string
|
||||
feedbackQty?: number
|
||||
feedbackImages?: string[]
|
||||
feedbackRemark?: string
|
||||
}) => request.post('/transport/order/scan/feedback', data),
|
||||
getApprovals: (id: string) => request.get<any[]>(`/transport/order/${id}/approvals`)
|
||||
}
|
||||
|
||||
@@ -1063,6 +1241,7 @@ export interface UnsettledPlanItem {
|
||||
licensePlate?: string
|
||||
transportCompany?: string
|
||||
freightAmount: number
|
||||
freightRemark?: string
|
||||
archiveTime?: string
|
||||
transportId: string
|
||||
transportNo?: string
|
||||
@@ -1092,6 +1271,7 @@ export interface SettlementPlanSummary {
|
||||
planDate?: string
|
||||
licensePlate?: string
|
||||
freightAmount?: number
|
||||
freightRemark?: string
|
||||
}
|
||||
|
||||
export interface SettlementApprovalFlowItem {
|
||||
@@ -1321,7 +1501,10 @@ export const inventoryApi = {
|
||||
exportLedger: (data: Record<string, any>) =>
|
||||
request.post('/transport/inventory/ledger/export', data, { responseType: 'blob' }),
|
||||
transactions: (params?: any) =>
|
||||
request.get<{ total: number; list: InventoryTransaction[] }>('/transport/inventory/transactions', { params }),
|
||||
request.get<{ total: number; list: InventoryTransaction[] }>(
|
||||
'/transport/inventory/transactions',
|
||||
{ params }
|
||||
),
|
||||
summary: (params: { groupBy: string; dateFrom: string; dateTo: string; productId?: string }) =>
|
||||
request.get<{ list: any[] }>('/transport/inventory/summary', { params }),
|
||||
warnings: (status?: string) =>
|
||||
@@ -1336,7 +1519,9 @@ export const inventoryApi = {
|
||||
highStockWarning?: number
|
||||
}) => request.post('/transport/inventory/warning-threshold', data),
|
||||
documentReminders: (status?: string) =>
|
||||
request.get<DocumentReminder[]>('/transport/inventory/document-reminders', { params: { status } }),
|
||||
request.get<DocumentReminder[]>('/transport/inventory/document-reminders', {
|
||||
params: { status }
|
||||
}),
|
||||
exportDocumentReminders: (data: Record<string, any>) =>
|
||||
request.post('/transport/inventory/document-reminders/export', data, { responseType: 'blob' }),
|
||||
documentReminderStats: () =>
|
||||
@@ -1467,10 +1652,15 @@ export const vehicleRechargeRecordApi = {
|
||||
{ params }
|
||||
),
|
||||
export: (data: Record<string, any>) =>
|
||||
request.post('/transport/vehicle-recharge-record/disburse-board/export', data, { responseType: 'blob' }),
|
||||
request.post('/transport/vehicle-recharge-record/disburse-board/export', data, {
|
||||
responseType: 'blob'
|
||||
}),
|
||||
list: (params?: Record<string, unknown>) =>
|
||||
request.get<VehicleRechargeRecordListResponse>('/transport/vehicle-recharge-record/', { params }),
|
||||
get: (id: string) => request.get<VehicleRechargeRecord>(`/transport/vehicle-recharge-record/${id}`),
|
||||
request.get<VehicleRechargeRecordListResponse>('/transport/vehicle-recharge-record/', {
|
||||
params
|
||||
}),
|
||||
get: (id: string) =>
|
||||
request.get<VehicleRechargeRecord>(`/transport/vehicle-recharge-record/${id}`),
|
||||
create: (data: Partial<VehicleRechargeRecord>) =>
|
||||
request.post<VehicleRechargeRecord>('/transport/vehicle-recharge-record/', data),
|
||||
update: (id: string, data: Partial<VehicleRechargeRecord>) =>
|
||||
@@ -1583,9 +1773,12 @@ export const vehicleMaintenanceApplyApi = {
|
||||
request.post<VehicleMaintenanceApply>(`/transport/vehicle-maintenance-apply/${id}/cancel`),
|
||||
delete: (ids: string) => request.delete(`/transport/vehicle-maintenance-apply/${ids}`),
|
||||
reminders: (licensePlate: string, excludeApplyId?: string) =>
|
||||
request.get<VehicleMaintenanceApplyReminder[]>('/transport/vehicle-maintenance-apply/reminders', {
|
||||
params: { licensePlate, excludeApplyId }
|
||||
})
|
||||
request.get<VehicleMaintenanceApplyReminder[]>(
|
||||
'/transport/vehicle-maintenance-apply/reminders',
|
||||
{
|
||||
params: { licensePlate, excludeApplyId }
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
export const vehicleMaintenanceProcessApi = {
|
||||
@@ -1595,7 +1788,9 @@ export const vehicleMaintenanceProcessApi = {
|
||||
{ params }
|
||||
),
|
||||
export: (data: Record<string, any>) =>
|
||||
request.post('/transport/vehicle-maintenance-process/process-board/export', data, { responseType: 'blob' }),
|
||||
request.post('/transport/vehicle-maintenance-process/process-board/export', data, {
|
||||
responseType: 'blob'
|
||||
}),
|
||||
get: (id: string) =>
|
||||
request.get<VehicleMaintenanceProcess>(`/transport/vehicle-maintenance-process/${id}`),
|
||||
create: (data: Partial<VehicleMaintenanceProcess>) =>
|
||||
@@ -1701,7 +1896,9 @@ export const vehicleUreaDisburseApi = {
|
||||
{ params }
|
||||
),
|
||||
export: (data: Record<string, any>) =>
|
||||
request.post('/transport/vehicle-urea-disburse/disburse-board/export', data, { responseType: 'blob' }),
|
||||
request.post('/transport/vehicle-urea-disburse/disburse-board/export', data, {
|
||||
responseType: 'blob'
|
||||
}),
|
||||
get: (id: string) => request.get<VehicleUreaDisburse>(`/transport/vehicle-urea-disburse/${id}`),
|
||||
create: (data: Partial<VehicleUreaDisburse>) =>
|
||||
request.post<VehicleUreaDisburse>('/transport/vehicle-urea-disburse/', data),
|
||||
|
||||
@@ -24,6 +24,44 @@ export interface PublicIoOrderItem {
|
||||
brandQtys?: BrandQtyItem[]
|
||||
}
|
||||
|
||||
export interface PublicIoOrderStopProduct {
|
||||
stopProductId: string
|
||||
planProductId?: string
|
||||
productName?: string
|
||||
aliasName?: string | null
|
||||
model?: string
|
||||
packageSpec?: string
|
||||
unit?: string
|
||||
quantity?: number
|
||||
actualQty?: number
|
||||
remark?: string
|
||||
brandMode?: string | null
|
||||
brandId?: string | null
|
||||
brandName?: string | null
|
||||
brandOptions?: { brandId: string; brandName: string }[]
|
||||
brandQtys?: BrandQtyItem[]
|
||||
}
|
||||
|
||||
export interface PublicIoOrderStop {
|
||||
stopType: 'load' | 'delivery'
|
||||
stopId: string
|
||||
seq?: number
|
||||
label: string
|
||||
customerName: string
|
||||
address?: string
|
||||
contact?: string
|
||||
notes?: string
|
||||
lng?: number | null
|
||||
lat?: number | null
|
||||
businessType?: string
|
||||
planQty?: number
|
||||
showProductQty?: boolean
|
||||
attachmentUrls?: string[]
|
||||
products?: PublicIoOrderStopProduct[]
|
||||
remark?: string
|
||||
feedbackTime?: string
|
||||
}
|
||||
|
||||
export interface PublicIoOrderPage {
|
||||
title?: string
|
||||
orderNo?: string
|
||||
@@ -53,6 +91,7 @@ export interface PublicIoOrderPage {
|
||||
voided: boolean
|
||||
archived?: boolean
|
||||
items: PublicIoOrderItem[]
|
||||
stops?: PublicIoOrderStop[]
|
||||
}
|
||||
|
||||
export interface PublicIoOrderHistoryProduct {
|
||||
@@ -122,7 +161,17 @@ export function createPublicIoOrderApi(kind: 'inbound' | 'outbound') {
|
||||
status: 'in_progress' | 'completed' | 'voided'
|
||||
remark?: string
|
||||
images?: string[]
|
||||
items: { id: string; actualQty: number; brandQtys?: BrandQtyItem[] }[]
|
||||
items?: { id: string; actualQty: number; brandQtys?: BrandQtyItem[] }[]
|
||||
stops?: {
|
||||
stopType: 'load' | 'delivery'
|
||||
stopId: string
|
||||
attachmentUrls?: string[]
|
||||
products: {
|
||||
stopProductId: string
|
||||
actualQty: number
|
||||
brandQtys?: BrandQtyItem[]
|
||||
}[]
|
||||
}[]
|
||||
}
|
||||
) => publicPlPost<{ success: boolean }>(`${base}/${token}/feedback`, data),
|
||||
uploadAttachment: (token: string, file: File) =>
|
||||
|
||||
@@ -0,0 +1,41 @@
|
||||
import { publicPlGet, publicPlPost, publicPlUpload } from '@/utils/http/public-pl'
|
||||
import type {
|
||||
PublicTransportHistoryPage,
|
||||
PublicTransportStop,
|
||||
PublicUploadResult
|
||||
} from '@/api/pl/public-transport'
|
||||
|
||||
export interface PublicTransportSitePage {
|
||||
planNo: string
|
||||
planDate?: string
|
||||
licensePlate?: string
|
||||
vehicleNo?: string
|
||||
planVoided?: boolean
|
||||
planArchived?: boolean
|
||||
stops: PublicTransportStop[]
|
||||
}
|
||||
|
||||
export const publicTransportSiteApi = {
|
||||
getPage: (token: string) =>
|
||||
publicPlGet<PublicTransportSitePage>(`/public/pl/transport-site/${token}`),
|
||||
getHistory: (token: string, date: string, keyword?: string) => {
|
||||
const params = new URLSearchParams({ date })
|
||||
const q = (keyword || '').trim()
|
||||
if (q) params.set('q', q)
|
||||
return publicPlGet<PublicTransportHistoryPage>(
|
||||
`/public/pl/transport-site/${token}/history?${params.toString()}`
|
||||
)
|
||||
},
|
||||
saveFeedback: (
|
||||
token: string,
|
||||
data: {
|
||||
stopType: 'load' | 'delivery'
|
||||
stopId: string
|
||||
quantity?: number
|
||||
attachmentUrls?: string[]
|
||||
remark?: string
|
||||
}
|
||||
) => publicPlPost<{ success: boolean }>(`/public/pl/transport-site/${token}/feedback`, data),
|
||||
uploadAttachment: (token: string, file: File) =>
|
||||
publicPlUpload<PublicUploadResult>(`/public/pl/transport-site/${token}/attachments`, file)
|
||||
}
|
||||
@@ -29,6 +29,44 @@ export interface PublicTransportPersonnel {
|
||||
role?: string
|
||||
}
|
||||
|
||||
export interface PublicTransportStopProduct {
|
||||
stopProductId: string
|
||||
planProductId?: string
|
||||
productName: string
|
||||
aliasName?: string | null
|
||||
model?: string
|
||||
packageSpec?: string
|
||||
unit?: string
|
||||
quantity?: number
|
||||
remark?: string
|
||||
brandMode?: string | null
|
||||
brandId?: string | null
|
||||
brandName?: string | null
|
||||
brandOptions?: { brandId: string; brandName: string }[]
|
||||
actualQty?: number | null
|
||||
brandQtys?: BrandQtyItem[]
|
||||
}
|
||||
|
||||
export interface PublicTransportStop {
|
||||
stopType: 'load' | 'delivery'
|
||||
stopId: string
|
||||
seq?: number
|
||||
label: string
|
||||
customerName: string
|
||||
address?: string
|
||||
contact?: string
|
||||
notes?: string
|
||||
lng?: number | null
|
||||
lat?: number | null
|
||||
businessType?: string
|
||||
planQty?: number | null
|
||||
quantity?: number | null
|
||||
products?: PublicTransportStopProduct[]
|
||||
attachmentUrls?: string[]
|
||||
remark?: string
|
||||
feedbackTime?: string
|
||||
}
|
||||
|
||||
export interface PublicTransportPage {
|
||||
planNo: string
|
||||
planDate?: string
|
||||
@@ -51,6 +89,7 @@ export interface PublicTransportPage {
|
||||
driverPhone?: string
|
||||
otherPersonnel?: PublicTransportPersonnel[]
|
||||
products: PublicTransportProduct[]
|
||||
stops?: PublicTransportStop[]
|
||||
feedbackRemark?: string
|
||||
feedbackImages: string[]
|
||||
feedbackQty?: number | null
|
||||
@@ -72,18 +111,39 @@ export interface PublicTransportHistoryProduct {
|
||||
unit?: string
|
||||
}
|
||||
|
||||
export interface PublicTransportHistoryStopProduct {
|
||||
productName: string
|
||||
model?: string
|
||||
packageSpec?: string
|
||||
quantity?: number | null
|
||||
unit?: string
|
||||
}
|
||||
|
||||
export interface PublicTransportHistoryStop {
|
||||
stopType: 'load' | 'delivery'
|
||||
seq?: number
|
||||
label: string
|
||||
customerName: string
|
||||
address?: string
|
||||
stopTime?: string
|
||||
products?: PublicTransportHistoryStopProduct[]
|
||||
}
|
||||
|
||||
export interface PublicTransportHistoryRecord {
|
||||
planId: string
|
||||
planNo: string
|
||||
transportId: string
|
||||
driverAccessToken?: string
|
||||
driverUrl?: string
|
||||
siteAccessToken?: string
|
||||
siteUrl?: string
|
||||
licensePlate?: string
|
||||
pickupTime?: string
|
||||
deliveryTime?: string
|
||||
pickupAddress?: string
|
||||
destinationAddress?: string
|
||||
products?: PublicTransportHistoryProduct[]
|
||||
stops?: PublicTransportHistoryStop[]
|
||||
planVoided?: boolean
|
||||
planArchived?: boolean
|
||||
statusLabel?: string
|
||||
@@ -92,6 +152,7 @@ export interface PublicTransportHistoryRecord {
|
||||
export interface PublicTransportHistoryPage {
|
||||
licensePlate?: string
|
||||
date: string
|
||||
keyword?: string
|
||||
records: PublicTransportHistoryRecord[]
|
||||
}
|
||||
|
||||
@@ -106,9 +167,20 @@ export const publicTransportApi = {
|
||||
data: {
|
||||
feedbackImages?: string[]
|
||||
feedbackRemark?: string
|
||||
products: { planProductId: string; actualQty: number; brandQtys?: BrandQtyItem[] }[]
|
||||
products?: { planProductId: string; actualQty: number; brandQtys?: BrandQtyItem[] }[]
|
||||
}
|
||||
) => publicPlPost<{ success: boolean }>(`/public/pl/transport/${token}/feedback`, data),
|
||||
uploadAttachment: (token: string, file: File) =>
|
||||
publicPlUpload<PublicUploadResult>(`/public/pl/transport/${token}/attachments`, file)
|
||||
publicPlUpload<PublicUploadResult>(`/public/pl/transport/${token}/attachments`, file),
|
||||
saveDriverStopFeedback: (
|
||||
token: string,
|
||||
data: {
|
||||
stopType: 'load' | 'delivery'
|
||||
stopId: string
|
||||
attachmentUrls: string[]
|
||||
products?: { stopProductId: string; actualQty: number; brandQtys?: BrandQtyItem[] }[]
|
||||
remark?: string
|
||||
}
|
||||
) =>
|
||||
publicPlPost<{ success: boolean }>(`/public/pl/transport/${token}/driver-feedback`, data)
|
||||
}
|
||||
@@ -0,0 +1,50 @@
|
||||
/* 运输计划类合并单元格列表(装货 + 多送货展平) */
|
||||
:deep(.pl-plan-merge-list-table) {
|
||||
.pl-plan-list-row--plan-striped > td.el-table__cell {
|
||||
background-color: #fafafa !important;
|
||||
}
|
||||
|
||||
.pl-plan-list-row--load > td.pl-plan-stop-col {
|
||||
background-color: #ecfdf5 !important;
|
||||
}
|
||||
|
||||
tbody tr.pl-plan-list-row:hover > td.el-table__cell {
|
||||
background-color: var(--el-table-row-hover-bg-color, #f1f5f9) !important;
|
||||
}
|
||||
|
||||
.pl-plan-list-row--plan-end > td {
|
||||
border-bottom-color: #94a3b8;
|
||||
border-bottom-width: 2px;
|
||||
}
|
||||
}
|
||||
|
||||
.pl-plan-stop-kind-text {
|
||||
font-size: 13px;
|
||||
color: var(--text, #1e293b);
|
||||
}
|
||||
|
||||
.pl-plan-stop-address-time {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 2px;
|
||||
width: 100%;
|
||||
text-align: left;
|
||||
}
|
||||
|
||||
.pl-plan-stop-address-time__addr {
|
||||
font-size: 13px;
|
||||
line-height: 1.45;
|
||||
color: var(--text, #1e293b);
|
||||
word-break: break-word;
|
||||
}
|
||||
|
||||
.pl-plan-stop-address-time__time {
|
||||
font-size: 12px;
|
||||
line-height: 1.4;
|
||||
color: var(--mint-text-muted, #64748b);
|
||||
}
|
||||
|
||||
.pl-plan-internal-customer-tag {
|
||||
margin-left: 6px;
|
||||
vertical-align: middle;
|
||||
}
|
||||
@@ -61,11 +61,16 @@ const props = withDefaults(
|
||||
}
|
||||
)
|
||||
|
||||
export type PlAddressApplyPayload = {
|
||||
address: string
|
||||
lng: number | null
|
||||
lat: number | null
|
||||
contact?: string
|
||||
}
|
||||
|
||||
const emit = defineEmits<{
|
||||
'update:modelValue': [value: string]
|
||||
'update:lng': [value: number | null]
|
||||
'update:lat': [value: number | null]
|
||||
'update:contact': [value: string]
|
||||
/** 地址库选中后一次性回写,避免父级多次 patch 互相覆盖 */
|
||||
apply: [value: PlAddressApplyPayload]
|
||||
}>()
|
||||
|
||||
/** 下拉默认最多展示条数 */
|
||||
@@ -101,16 +106,23 @@ function formatAddressContact(row: TransportAddress): string {
|
||||
return name || phone
|
||||
}
|
||||
|
||||
function emitApply(payload: PlAddressApplyPayload) {
|
||||
emit('apply', payload)
|
||||
}
|
||||
|
||||
function applyAddressRow(row: TransportAddress) {
|
||||
selectedId.value = row.id
|
||||
legacyOption.value = null
|
||||
emit('update:modelValue', row.fullAddress || '')
|
||||
emit('update:lng', row.lng != null ? Number(row.lng) : null)
|
||||
emit('update:lat', row.lat != null ? Number(row.lat) : null)
|
||||
const contactText = formatAddressContact(row)
|
||||
if (contactText) {
|
||||
emit('update:contact', contactText)
|
||||
const payload: PlAddressApplyPayload = {
|
||||
address: row.fullAddress || '',
|
||||
lng: row.lng != null ? Number(row.lng) : null,
|
||||
lat: row.lat != null ? Number(row.lat) : null
|
||||
}
|
||||
if (contactText) {
|
||||
payload.contact = contactText
|
||||
}
|
||||
emitApply(payload)
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -142,9 +154,7 @@ function handleFocus() {
|
||||
function handleClear() {
|
||||
selectedId.value = ''
|
||||
legacyOption.value = null
|
||||
emit('update:modelValue', '')
|
||||
emit('update:lng', null)
|
||||
emit('update:lat', null)
|
||||
emitApply({ address: '', lng: null, lat: null })
|
||||
}
|
||||
|
||||
function handleSelectChange(id: string) {
|
||||
@@ -156,7 +166,11 @@ function handleSelectChange(id: string) {
|
||||
if (!row) return
|
||||
if (row.id.startsWith('legacy-')) {
|
||||
selectedId.value = row.id
|
||||
emit('update:modelValue', row.fullAddress || '')
|
||||
emitApply({
|
||||
address: row.fullAddress || '',
|
||||
lng: props.lng ?? null,
|
||||
lat: props.lat ?? null
|
||||
})
|
||||
return
|
||||
}
|
||||
applyAddressRow(row)
|
||||
|
||||
@@ -154,7 +154,7 @@ function openBlank() {
|
||||
visible.value = true
|
||||
}
|
||||
|
||||
async function open(planIdOrIds: string | string[]) {
|
||||
async function open(planIdOrIds: string | string[], options?: { customerId?: string }) {
|
||||
const ids = normalizePlanIds(planIdOrIds)
|
||||
if (!ids.length) {
|
||||
ElMessage.warning('无法获取计划ID')
|
||||
@@ -175,7 +175,12 @@ async function open(planIdOrIds: string | string[]) {
|
||||
return (res.data ?? res) as Plan
|
||||
})
|
||||
)
|
||||
const plan = ids.length === 1 ? plans[0] : buildBatchPrintPlanView(plans)
|
||||
let plan = ids.length === 1 ? plans[0] : buildBatchPrintPlanView(plans)
|
||||
const customerId = String(options?.customerId || '').trim()
|
||||
if (customerId && ids.length === 1) {
|
||||
const { applyDeliveryCustomerToPlan } = await import('@/utils/pl-delivery-slip-print')
|
||||
plan = applyDeliveryCustomerToPlan(plan, customerId)
|
||||
}
|
||||
currentPlan.value = plan
|
||||
|
||||
let htmlContent = ''
|
||||
@@ -196,7 +201,7 @@ async function open(planIdOrIds: string | string[]) {
|
||||
visible.value = true
|
||||
} catch (error) {
|
||||
console.error('打开送(提)货单打印失败', error)
|
||||
ElMessage.error('加载送(提)货单失败')
|
||||
ElMessage.error(error instanceof Error ? error.message : '加载送(提)货单失败')
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -131,6 +131,35 @@
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<section v-if="settlement?.plans?.length" class="view-section">
|
||||
<h4 class="view-section-title">关联计划</h4>
|
||||
<div class="panel dialog-list-panel">
|
||||
<div class="list-body list-wrap dialog-list-body-only">
|
||||
<ListTable table-key="business-pl-freight-settlement-view-dialog-plans"
|
||||
:data="settlement.plans || []"
|
||||
class="list-table"
|
||||
stripe
|
||||
empty-text="暂无数据"
|
||||
>
|
||||
<el-table-column type="index" label="序号" width="60" align="center" />
|
||||
<el-table-column prop="planNo" label="计划编号" min-width="160" show-overflow-tooltip />
|
||||
<el-table-column prop="planDate" label="计划日期" min-width="120" align="center">
|
||||
<template #default="{ row }">{{ row.planDate || '—' }}</template>
|
||||
</el-table-column>
|
||||
<el-table-column prop="licensePlate" label="车牌号" min-width="140" show-overflow-tooltip>
|
||||
<template #default="{ row }">{{ row.licensePlate || '—' }}</template>
|
||||
</el-table-column>
|
||||
<el-table-column prop="freightAmount" label="运费(元)" min-width="110" align="right">
|
||||
<template #default="{ row }">{{ formatAmount(row.freightAmount) }}</template>
|
||||
</el-table-column>
|
||||
<el-table-column prop="freightRemark" label="运费备注" min-width="180" show-overflow-tooltip>
|
||||
<template #default="{ row }">{{ row.freightRemark || '—' }}</template>
|
||||
</el-table-column>
|
||||
</ListTable>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<section
|
||||
v-if="settlement && (settlement.approvalFlow?.length || settlement.approvalHistory?.length)"
|
||||
class="view-section"
|
||||
|
||||
File diff suppressed because it is too large.
Load diff
@@ -1,6 +1,10 @@
|
||||
<!-- eslint-disable vue/no-v-model-argument -->
|
||||
<template>
|
||||
<div class="pl-plan-contract-panel" v-loading="loadingDetails">
|
||||
<div
|
||||
class="pl-plan-contract-panel"
|
||||
:class="{ 'is-compact-summary': compactSummary }"
|
||||
v-loading="loadingDetails"
|
||||
>
|
||||
<slot
|
||||
name="toolbar"
|
||||
:open="openSelector"
|
||||
@@ -26,75 +30,105 @@
|
||||
<span class="pl-plan-contract-card__no">{{ row.contractNo || row.id || '—' }}</span>
|
||||
<DictTag dict-type="crm_contract_type" :value="row.contractType" />
|
||||
<span class="pl-plan-contract-card__count">
|
||||
{{ row.products?.length || 0 }} 个产品
|
||||
{{ formatContractProductCount(row) }}
|
||||
</span>
|
||||
</div>
|
||||
<div class="pl-plan-contract-card__actions">
|
||||
<el-button link type="primary" @click="handleViewContract(String(row.id))">
|
||||
<el-icon><View /></el-icon>查看
|
||||
<el-button
|
||||
v-if="compactSummary && row.products?.length"
|
||||
link
|
||||
type="primary"
|
||||
@click="toggleExpand(String(row.id))"
|
||||
>
|
||||
<el-icon>
|
||||
<ArrowDown v-if="!isExpanded(String(row.id))" />
|
||||
<ArrowUp v-else />
|
||||
</el-icon>
|
||||
{{ isExpanded(String(row.id)) ? '收起产品明细' : '展开产品明细' }}
|
||||
</el-button>
|
||||
<el-button v-if="!readonly" link type="danger" @click="removeContract(String(row.id))">
|
||||
<el-icon><Delete /></el-icon>移除
|
||||
<el-button
|
||||
link
|
||||
type="primary"
|
||||
title="查看"
|
||||
aria-label="查看"
|
||||
@click="handleViewContract(String(row.id))"
|
||||
>
|
||||
<el-icon><View /></el-icon>
|
||||
</el-button>
|
||||
<el-button
|
||||
v-if="!readonly"
|
||||
link
|
||||
type="danger"
|
||||
title="移除"
|
||||
aria-label="移除"
|
||||
@click="removeContract(String(row.id))"
|
||||
>
|
||||
<el-icon><Delete /></el-icon>
|
||||
</el-button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div v-if="row.products?.length" class="pl-plan-contract-card__body">
|
||||
<div class="pl-plan-contract-card__table-scroll">
|
||||
<el-table
|
||||
:data="row.products"
|
||||
class="list-table pl-plan-contract-card__table"
|
||||
size="small"
|
||||
stripe
|
||||
>
|
||||
<el-table-column label="产品名称" min-width="110" align="left" show-overflow-tooltip>
|
||||
<template #default="{ row: product }">
|
||||
{{ product.standardProductName || product.productName || '—' }}
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="别名" min-width="80" align="center" show-overflow-tooltip>
|
||||
<template #default="{ row: product }">
|
||||
{{ product.aliasName || '—' }}
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="品牌" min-width="72" align="center" show-overflow-tooltip>
|
||||
<template #default="{ row: product }">
|
||||
{{ formatBrandConstraintLabel(product.brandMode, product.brandName) }}
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="型号/规格" min-width="90" align="center" show-overflow-tooltip>
|
||||
<template #default="{ row: product }">
|
||||
{{ product.model || product.productModel || '—' }}
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="数量" min-width="64" align="right" show-overflow-tooltip>
|
||||
<template #default="{ row: product }">
|
||||
{{ product.quantity ?? '—' }}
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="单位" min-width="56" align="center">
|
||||
<template #default="{ row: product }">
|
||||
<DictTag dict-type="crm_product_unit" :value="product.unit" />
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="包装规格" min-width="90" align="center" show-overflow-tooltip>
|
||||
<template #default="{ row: product }">
|
||||
{{ product.packageSpec || '—' }}
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="送货方式" min-width="80" align="center" show-overflow-tooltip>
|
||||
<template #default="{ row: product }">
|
||||
{{ product.deliveryMethod || '—' }}
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="备注" min-width="90" align="left" show-overflow-tooltip>
|
||||
<template #default="{ row: product }">
|
||||
{{ product.remark || '—' }}
|
||||
</template>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
<template v-if="row.products?.length">
|
||||
<div
|
||||
v-if="!compactSummary || isExpanded(String(row.id))"
|
||||
class="pl-plan-contract-card__body"
|
||||
>
|
||||
<div class="pl-plan-contract-card__table-scroll">
|
||||
<el-table
|
||||
:data="row.products"
|
||||
class="list-table pl-plan-contract-card__table"
|
||||
size="small"
|
||||
stripe
|
||||
>
|
||||
<el-table-column label="产品名称" min-width="110" align="left" show-overflow-tooltip>
|
||||
<template #default="{ row: product }">
|
||||
{{ product.standardProductName || product.productName || '—' }}
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="别名" min-width="80" align="center" show-overflow-tooltip>
|
||||
<template #default="{ row: product }">
|
||||
{{ product.aliasName || '—' }}
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="品牌" min-width="72" align="center" show-overflow-tooltip>
|
||||
<template #default="{ row: product }">
|
||||
{{ formatBrandConstraintLabel(product.brandMode, product.brandName) }}
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="型号/规格" min-width="90" align="center" show-overflow-tooltip>
|
||||
<template #default="{ row: product }">
|
||||
{{ product.model || product.productModel || '—' }}
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="数量" min-width="64" align="right" show-overflow-tooltip>
|
||||
<template #default="{ row: product }">
|
||||
{{ product.quantity ?? '—' }}
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="单位" min-width="56" align="center">
|
||||
<template #default="{ row: product }">
|
||||
<DictTag dict-type="crm_product_unit" :value="product.unit" />
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="包装规格" min-width="90" align="center" show-overflow-tooltip>
|
||||
<template #default="{ row: product }">
|
||||
{{ product.packageSpec || '—' }}
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="送货方式" min-width="80" align="center" show-overflow-tooltip>
|
||||
<template #default="{ row: product }">
|
||||
{{ product.deliveryMethod || '—' }}
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="备注" min-width="90" align="left" show-overflow-tooltip>
|
||||
<template #default="{ row: product }">
|
||||
{{ product.remark || '—' }}
|
||||
</template>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
<p v-else class="pl-plan-contract-card__empty">暂无产品明细</p>
|
||||
</article>
|
||||
</div>
|
||||
@@ -122,7 +156,7 @@
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { Delete, Search, View } from '@element-plus/icons-vue'
|
||||
import { ArrowDown, ArrowUp, Delete, Search, View } from '@element-plus/icons-vue'
|
||||
import { getContract } from '@/api/crm/contract'
|
||||
import type { ContractProductForm, ContractVO } from '@/api/crm/contract/types'
|
||||
import { fetchProductDetail } from '@/api/crm/product'
|
||||
@@ -147,12 +181,15 @@ const props = withDefaults(
|
||||
required?: boolean
|
||||
/** 只读:展示合同卡片,标题栏提供「查看」 */
|
||||
readonly?: boolean
|
||||
/** 段内窄栏:默认仅合同摘要(含产品名称),展开后显示完整产品表 */
|
||||
compactSummary?: boolean
|
||||
selectableStatuses?: string[]
|
||||
}>(),
|
||||
{
|
||||
disabled: false,
|
||||
required: false,
|
||||
readonly: false,
|
||||
compactSummary: false,
|
||||
selectableStatuses: () => ['approved', 'executing']
|
||||
}
|
||||
)
|
||||
@@ -167,6 +204,42 @@ const detailRows = ref<ContractVO[]>([])
|
||||
const loadingDetails = ref(false)
|
||||
const contractDetailDialogActive = ref(false)
|
||||
const contractDetailRef = ref<InstanceType<typeof ContractDetailDialog>>()
|
||||
const expandedContractIds = ref<Set<string>>(new Set())
|
||||
|
||||
function isExpanded(contractId: string) {
|
||||
return expandedContractIds.value.has(contractId)
|
||||
}
|
||||
|
||||
function toggleExpand(contractId: string) {
|
||||
const id = String(contractId || '').trim()
|
||||
if (!id) return
|
||||
const next = new Set(expandedContractIds.value)
|
||||
if (next.has(id)) next.delete(id)
|
||||
else next.add(id)
|
||||
expandedContractIds.value = next
|
||||
}
|
||||
|
||||
function contractProductName(product: ContractProductForm) {
|
||||
return product.standardProductName || product.productName || '—'
|
||||
}
|
||||
|
||||
/** 摘要标题:N个产品(名称1、名称2…);超过 5 个时末尾加 … */
|
||||
function formatContractProductCount(row: ContractVO) {
|
||||
const products = row.products || []
|
||||
const count = products.length
|
||||
if (!count) return '0个产品'
|
||||
const names = products
|
||||
.map(product => {
|
||||
const name = String(contractProductName(product) || '').trim()
|
||||
return name && name !== '—' ? name : ''
|
||||
})
|
||||
.filter(Boolean)
|
||||
if (!names.length) return `${count}个产品`
|
||||
const maxShow = 5
|
||||
const shown = names.slice(0, maxShow)
|
||||
const suffix = names.length > maxShow ? '、...' : ''
|
||||
return `${count}个产品(${shown.join('、')}${suffix})`
|
||||
}
|
||||
|
||||
const selectedIds = computed(() =>
|
||||
(props.modelValue || []).map(item => String(item.contractId)).filter(Boolean)
|
||||
@@ -265,6 +338,9 @@ async function handleConfirmMultiple(contracts: ContractVO[]) {
|
||||
function removeContract(id: string) {
|
||||
const next = detailRows.value.filter(item => String(item.id) !== id)
|
||||
detailRows.value = next
|
||||
const expanded = new Set(expandedContractIds.value)
|
||||
expanded.delete(String(id))
|
||||
expandedContractIds.value = expanded
|
||||
emitLinksFromDetails(next)
|
||||
}
|
||||
|
||||
@@ -290,6 +366,7 @@ watch(
|
||||
if (props.readonly) return
|
||||
if (prev && id !== prev) {
|
||||
detailRows.value = []
|
||||
expandedContractIds.value = new Set()
|
||||
emit('update:modelValue', [])
|
||||
}
|
||||
}
|
||||
@@ -312,6 +389,7 @@ watch(
|
||||
.pl-plan-contract-panel {
|
||||
width: 100%;
|
||||
min-width: 0;
|
||||
margin-bottom: 12px;
|
||||
}
|
||||
|
||||
.pl-plan-contract-panel__toolbar {
|
||||
@@ -355,6 +433,10 @@ watch(
|
||||
border-bottom: 1px solid #a7f3d0;
|
||||
}
|
||||
|
||||
.pl-plan-contract-panel.is-compact-summary .pl-plan-contract-card__head {
|
||||
border-bottom: none;
|
||||
}
|
||||
|
||||
.pl-plan-contract-card__meta {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
|
||||
@@ -0,0 +1,117 @@
|
||||
<!-- 送(提)货单:多送货客户时单选 -->
|
||||
<template>
|
||||
<el-dialog
|
||||
v-model="innerVisible"
|
||||
title="选择送货客户"
|
||||
width="480px"
|
||||
align-center
|
||||
append-to-body
|
||||
destroy-on-close
|
||||
class="dialog-form-layout pl-plan-delivery-customer-select-dialog"
|
||||
modal-class="order-module-dialog-mask"
|
||||
:close-on-click-modal="false"
|
||||
@closed="handleClosed"
|
||||
>
|
||||
<p class="select-hint">该计划存在多个送货客户,请选择本次打印的收货单位。</p>
|
||||
<el-radio-group v-model="selectedCustomerId" class="customer-radio-group">
|
||||
<el-radio
|
||||
v-for="item in customers"
|
||||
:key="item.customerId"
|
||||
:value="item.customerId"
|
||||
class="customer-radio-item"
|
||||
>
|
||||
<span class="customer-name">{{ item.customerName }}</span>
|
||||
<span v-if="item.deliveryCount > 1" class="form-label-tip">({{ item.deliveryCount }} 段合并)</span>
|
||||
</el-radio>
|
||||
</el-radio-group>
|
||||
<template #footer>
|
||||
<div class="dialog-footer">
|
||||
<el-button @click="innerVisible = false">
|
||||
<el-icon><Close /></el-icon>取消
|
||||
</el-button>
|
||||
<el-button type="primary" :disabled="!selectedCustomerId" @click="handleConfirm">
|
||||
<el-icon><Check /></el-icon>确定
|
||||
</el-button>
|
||||
</div>
|
||||
</template>
|
||||
</el-dialog>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { Check, Close } from '@element-plus/icons-vue'
|
||||
import type { DeliveryPrintCustomerOption } from '@/utils/pl-delivery-slip-print'
|
||||
|
||||
const emit = defineEmits<{
|
||||
confirm: [customerId: string]
|
||||
}>()
|
||||
|
||||
const innerVisible = ref(false)
|
||||
const customers = ref<DeliveryPrintCustomerOption[]>([])
|
||||
const selectedCustomerId = ref('')
|
||||
let resolveSelect: ((customerId: string | null) => void) | null = null
|
||||
|
||||
function handleClosed() {
|
||||
customers.value = []
|
||||
selectedCustomerId.value = ''
|
||||
if (resolveSelect) {
|
||||
resolveSelect(null)
|
||||
resolveSelect = null
|
||||
}
|
||||
}
|
||||
|
||||
function handleConfirm() {
|
||||
if (!selectedCustomerId.value) {
|
||||
ElMessage.warning('请选择送货客户')
|
||||
return
|
||||
}
|
||||
const customerId = selectedCustomerId.value
|
||||
const done = resolveSelect
|
||||
resolveSelect = null
|
||||
innerVisible.value = false
|
||||
done?.(customerId)
|
||||
emit('confirm', customerId)
|
||||
}
|
||||
|
||||
/** 打开弹窗并等待用户选择;取消返回 null */
|
||||
function open(options: DeliveryPrintCustomerOption[]): Promise<string | null> {
|
||||
customers.value = options || []
|
||||
selectedCustomerId.value = options.length === 1 ? options[0].customerId : ''
|
||||
innerVisible.value = true
|
||||
return new Promise((resolve) => {
|
||||
resolveSelect = resolve
|
||||
})
|
||||
}
|
||||
|
||||
defineExpose({ open })
|
||||
</script>
|
||||
|
||||
<style scoped lang="scss">
|
||||
.select-hint {
|
||||
margin: 0 0 12px;
|
||||
font-size: 13px;
|
||||
color: var(--mint-text-muted, #64748b);
|
||||
line-height: 1.5;
|
||||
}
|
||||
|
||||
.customer-radio-group {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: stretch;
|
||||
gap: 8px;
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.customer-radio-item {
|
||||
margin-right: 0;
|
||||
height: auto;
|
||||
padding: 10px 12px;
|
||||
border: 1px solid #e2e8f0;
|
||||
border-radius: 8px;
|
||||
background: #f8fafc;
|
||||
}
|
||||
|
||||
.customer-name {
|
||||
font-size: 14px;
|
||||
color: #1e293b;
|
||||
}
|
||||
</style>
|
||||
@@ -0,0 +1,708 @@
|
||||
<!-- eslint-disable vue/no-v-model-argument -->
|
||||
<template>
|
||||
<div class="pl-plan-delivery-section">
|
||||
<div v-if="tabMode" class="pl-plan-delivery-tabs">
|
||||
<button
|
||||
v-for="(delivery, index) in modelValue"
|
||||
:key="delivery.seq + '-' + index"
|
||||
type="button"
|
||||
class="pl-plan-delivery-tab"
|
||||
:class="{ 'is-active': activeIndex === index }"
|
||||
@click="activeIndex = index"
|
||||
>
|
||||
#{{ delivery.seq || index + 1 }}
|
||||
{{ delivery.customerName || '未选客户' }}
|
||||
<span v-if="segmentQtyLabel(delivery)" class="pl-plan-delivery-tab__qty">
|
||||
{{ segmentQtyLabel(delivery) }}
|
||||
</span>
|
||||
</button>
|
||||
</div>
|
||||
|
||||
<div v-else class="pl-plan-delivery-section__toolbar">
|
||||
<p class="pl-plan-delivery-section__hint">支持多个送货客户;数量不平衡仅告警,可暂存。</p>
|
||||
</div>
|
||||
|
||||
<article
|
||||
v-for="(delivery, index) in modelValue"
|
||||
v-show="!tabMode || activeIndex === index"
|
||||
:key="delivery.seq + '-' + index"
|
||||
class="pl-plan-delivery-card"
|
||||
:class="{ 'is-tab-panel': tabMode }"
|
||||
>
|
||||
<header v-if="!tabMode" class="pl-plan-delivery-card__head">
|
||||
<h4 class="pl-plan-delivery-card__title">送货段 #{{ delivery.seq || index + 1 }}</h4>
|
||||
<div class="pl-plan-delivery-card__actions">
|
||||
<el-button
|
||||
v-if="index > 0"
|
||||
class="btn-ghost"
|
||||
size="small"
|
||||
@click="moveDelivery(index, -1)"
|
||||
>
|
||||
<el-icon><Top /></el-icon>上移
|
||||
</el-button>
|
||||
<el-button
|
||||
v-if="index < modelValue.length - 1"
|
||||
class="btn-ghost"
|
||||
size="small"
|
||||
@click="moveDelivery(index, 1)"
|
||||
>
|
||||
<el-icon><Bottom /></el-icon>下移
|
||||
</el-button>
|
||||
<el-button
|
||||
v-if="modelValue.length > 1"
|
||||
class="btn-ghost"
|
||||
size="small"
|
||||
type="danger"
|
||||
@click="removeDelivery(index)"
|
||||
>
|
||||
<el-icon><Delete /></el-icon>删除
|
||||
</el-button>
|
||||
</div>
|
||||
</header>
|
||||
|
||||
<PlPlanContractMultiSelect
|
||||
v-model="delivery.contracts"
|
||||
:customer-id="delivery.customerId"
|
||||
:disabled="!delivery.customerId || isPlInternalCustomerName(delivery.customerName)"
|
||||
:required="false"
|
||||
compact-summary
|
||||
>
|
||||
<template #toolbar="{ open, disabled, hint, hintWarn }">
|
||||
<div class="pl-plan-party-select-row">
|
||||
<el-form-item label="送货客户" required class="pl-plan-party-select-row__customer">
|
||||
<div class="customer-select-row">
|
||||
<el-select
|
||||
:model-value="delivery.customerId"
|
||||
class="customer-select-row__select"
|
||||
filterable
|
||||
remote
|
||||
clearable
|
||||
:remote-method="(q) => searchCustomerOptions(q, index)"
|
||||
:loading="customerOptionsLoading[index]"
|
||||
placeholder="客户名称/拼音首字母"
|
||||
@focus="handleCustomerSelectFocus(index)"
|
||||
@update:model-value="(val) => handleCustomerChange(index, val)"
|
||||
>
|
||||
<el-option
|
||||
v-for="item in customerOptionsByIndex[index] || []"
|
||||
:key="item.id"
|
||||
:label="item.customerName"
|
||||
:value="item.id"
|
||||
/>
|
||||
</el-select>
|
||||
<el-button
|
||||
text
|
||||
class="customer-select-row__search"
|
||||
@click="emit('open-customer-picker', index)"
|
||||
>
|
||||
<el-icon><Search /></el-icon>
|
||||
</el-button>
|
||||
</div>
|
||||
</el-form-item>
|
||||
<el-form-item label="送货合同" class="pl-plan-party-select-row__contract">
|
||||
<div class="pl-plan-contract-trigger">
|
||||
<el-button class="btn-ghost" :disabled="disabled" @click="open">
|
||||
<el-icon><Search /></el-icon>选择合同
|
||||
</el-button>
|
||||
<span
|
||||
v-if="hint"
|
||||
class="pl-plan-contract-trigger__hint"
|
||||
:class="{ 'is-warn': hintWarn }"
|
||||
>
|
||||
{{ hint }}
|
||||
</span>
|
||||
</div>
|
||||
</el-form-item>
|
||||
</div>
|
||||
</template>
|
||||
</PlPlanContractMultiSelect>
|
||||
|
||||
<div class="form-grid-2">
|
||||
<el-form-item label="送货时间">
|
||||
<el-date-picker
|
||||
:model-value="delivery.deliveryTime"
|
||||
type="date"
|
||||
placeholder="选择送货时间"
|
||||
value-format="YYYY-MM-DD"
|
||||
style="width: 100%"
|
||||
@update:model-value="patchDelivery(index, { deliveryTime: $event || '' })"
|
||||
/>
|
||||
</el-form-item>
|
||||
<el-form-item label="联系方式">
|
||||
<el-input
|
||||
:model-value="delivery.contact"
|
||||
placeholder="联系方式"
|
||||
@update:model-value="patchDelivery(index, { contact: $event })"
|
||||
/>
|
||||
</el-form-item>
|
||||
<el-form-item label="送货地址" class="form-col-span-2">
|
||||
<PlAddressWithLibrary
|
||||
:model-value="delivery.address"
|
||||
:lng="delivery.lng"
|
||||
:lat="delivery.lat"
|
||||
:contact="delivery.contact"
|
||||
placeholder="送货地址"
|
||||
@apply="patchDeliveryAddress(index, $event)"
|
||||
/>
|
||||
</el-form-item>
|
||||
<el-form-item label="注意事项" class="form-col-span-2">
|
||||
<el-input
|
||||
:model-value="delivery.notes"
|
||||
placeholder="送货注意事项"
|
||||
@update:model-value="patchDelivery(index, { notes: $event })"
|
||||
/>
|
||||
</el-form-item>
|
||||
<el-form-item label="地磅单" class="form-col-span-2">
|
||||
<div class="pl-plan-dibang-row">
|
||||
<el-checkbox
|
||||
:model-value="delivery.generateDibang === 1"
|
||||
:disabled="isDibangLocked"
|
||||
@update:model-value="(checked) => handleDibangToggle(index, checked)"
|
||||
>
|
||||
生成地磅单({{ directionLabel(delivery.dibangDirection) }})
|
||||
</el-checkbox>
|
||||
<span v-if="isDibangLocked" class="pl-plan-dibang-row__hint">
|
||||
装货客户为内部客户时默认勾选
|
||||
</span>
|
||||
</div>
|
||||
</el-form-item>
|
||||
</div>
|
||||
|
||||
<div class="pl-plan-stop-products-head">
|
||||
<span class="pl-plan-stop-products-head__title">送货产品</span>
|
||||
<el-button
|
||||
v-if="!readonly"
|
||||
class="btn-ghost"
|
||||
size="small"
|
||||
@click="emit('sync-products', index)"
|
||||
>
|
||||
<el-icon><Refresh /></el-icon>从装货同步
|
||||
</el-button>
|
||||
</div>
|
||||
<p v-if="showSplitHint" class="pl-plan-delivery-section__split-hint">
|
||||
多个送货段,请拆分各段数量
|
||||
</p>
|
||||
<p v-if="!delivery.products.length" class="pl-plan-delivery-section__empty-hint">
|
||||
请先在装货区添加产品,将自动同步到送货段
|
||||
</p>
|
||||
<PlPlanStopProductTable
|
||||
:products="delivery.products"
|
||||
:editable="!readonly"
|
||||
:compact="compactProducts"
|
||||
:allow-remove="false"
|
||||
:shared-readonly="true"
|
||||
@remove="(productIndex) => removeStopProduct(index, productIndex)"
|
||||
/>
|
||||
</article>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { Bottom, Delete, Refresh, Search, Top } from '@element-plus/icons-vue'
|
||||
import { fetchCustomerOptions } from '@/api/crm/customer'
|
||||
import { customerStopPrefApi, type CustomerStopPref } from '@/api/pl/index'
|
||||
import PlAddressWithLibrary, {
|
||||
type PlAddressApplyPayload
|
||||
} from '@/components/business/pl-address-with-library/index.vue'
|
||||
import PlPlanContractMultiSelect from '@/components/business/pl-plan-contract-multi-select/index.vue'
|
||||
import PlPlanStopProductTable from '@/components/business/pl-plan-stop-product-table/index.vue'
|
||||
import {
|
||||
createEmptyDeliveryForm,
|
||||
sumStopProductsPlanQty,
|
||||
type PlanDeliveryForm
|
||||
} from '@/utils/pl-plan-stop-form'
|
||||
import { isPlInternalCustomerName } from '@/utils/pl-internal-customer'
|
||||
import { pickBxData } from '@/utils/http/bx'
|
||||
|
||||
const props = withDefaults(
|
||||
defineProps<{
|
||||
modelValue: PlanDeliveryForm[]
|
||||
loadCustomerName?: string
|
||||
tabMode?: boolean
|
||||
readonly?: boolean
|
||||
compactProducts?: boolean
|
||||
qtyUnitLabel?: string
|
||||
/** 多送货段时提示拆分数量 */
|
||||
showSplitHint?: boolean
|
||||
}>(),
|
||||
{
|
||||
loadCustomerName: '',
|
||||
tabMode: true,
|
||||
readonly: false,
|
||||
compactProducts: true,
|
||||
qtyUnitLabel: '',
|
||||
showSplitHint: false
|
||||
}
|
||||
)
|
||||
|
||||
const emit = defineEmits<{
|
||||
'update:modelValue': [value: PlanDeliveryForm[]]
|
||||
'open-customer-picker': [index: number]
|
||||
'sync-products': [index: number]
|
||||
'add-delivery': []
|
||||
'active-index-change': [index: number]
|
||||
}>()
|
||||
|
||||
interface CustomerOptionRow {
|
||||
id: string
|
||||
customerName: string
|
||||
customerNo?: string
|
||||
}
|
||||
|
||||
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,
|
||||
(len) => {
|
||||
if (activeIndex.value >= len) {
|
||||
activeIndex.value = Math.max(0, len - 1)
|
||||
}
|
||||
}
|
||||
)
|
||||
|
||||
watch(
|
||||
activeIndex,
|
||||
(index) => {
|
||||
emit('active-index-change', index)
|
||||
},
|
||||
{ immediate: true }
|
||||
)
|
||||
|
||||
function resequence(list: PlanDeliveryForm[]) {
|
||||
return list.map((row, index) => ({ ...row, seq: index + 1 }))
|
||||
}
|
||||
|
||||
function patchDelivery(index: number, partial: Partial<PlanDeliveryForm>) {
|
||||
const next = props.modelValue.map((row, i) => (i === index ? { ...row, ...partial } : row))
|
||||
emit('update:modelValue', next)
|
||||
}
|
||||
|
||||
function patchDeliveryAddress(index: number, fields: PlAddressApplyPayload) {
|
||||
const partial: Partial<PlanDeliveryForm> = {
|
||||
address: fields.address,
|
||||
lng: fields.lng,
|
||||
lat: fields.lat
|
||||
}
|
||||
if (fields.contact !== undefined) {
|
||||
partial.contact = fields.contact
|
||||
}
|
||||
patchDelivery(index, partial)
|
||||
}
|
||||
|
||||
function removeStopProduct(deliveryIndex: number, productIndex: number) {
|
||||
const delivery = props.modelValue[deliveryIndex]
|
||||
if (!delivery) return
|
||||
patchDelivery(deliveryIndex, {
|
||||
products: delivery.products.filter((_, i) => i !== productIndex)
|
||||
})
|
||||
}
|
||||
|
||||
function addDelivery() {
|
||||
const nextSeq = props.modelValue.length + 1
|
||||
emit('update:modelValue', resequence([
|
||||
...props.modelValue,
|
||||
createEmptyDeliveryForm(nextSeq, props.loadCustomerName)
|
||||
]))
|
||||
activeIndex.value = props.modelValue.length
|
||||
emit('add-delivery')
|
||||
}
|
||||
|
||||
function removeDelivery(index: number) {
|
||||
const next = props.modelValue.filter((_, i) => i !== index)
|
||||
emit('update:modelValue', resequence(
|
||||
next.length ? next : [createEmptyDeliveryForm(1, props.loadCustomerName)]
|
||||
))
|
||||
if (activeIndex.value >= index && activeIndex.value > 0) {
|
||||
activeIndex.value -= 1
|
||||
}
|
||||
}
|
||||
|
||||
function moveDelivery(index: number, delta: number) {
|
||||
const target = index + delta
|
||||
if (target < 0 || target >= props.modelValue.length) return
|
||||
const next = [...props.modelValue]
|
||||
const temp = next[index]
|
||||
next[index] = next[target]
|
||||
next[target] = temp
|
||||
emit('update:modelValue', resequence(next))
|
||||
if (activeIndex.value === index) {
|
||||
activeIndex.value = target
|
||||
} else if (activeIndex.value === target) {
|
||||
activeIndex.value = index
|
||||
}
|
||||
}
|
||||
|
||||
function segmentQtyLabel(delivery: PlanDeliveryForm) {
|
||||
const qty = sumStopProductsPlanQty(delivery.products || [])
|
||||
if (qty <= 0) return ''
|
||||
const unit = props.qtyUnitLabel || ''
|
||||
const text = String(parseFloat(qty.toFixed(3)))
|
||||
return unit ? `${text}${unit}` : text
|
||||
}
|
||||
|
||||
function directionLabel(direction?: string) {
|
||||
if (direction === 'outbound') return '出库'
|
||||
if (direction === 'inbound') return '入库'
|
||||
return '无'
|
||||
}
|
||||
|
||||
function extractCustomerOptions(res: unknown): CustomerOptionRow[] {
|
||||
const unwrapped = (res as { data?: unknown })?.data ?? res
|
||||
if (Array.isArray(unwrapped)) return unwrapped as CustomerOptionRow[]
|
||||
const payload = (unwrapped as { list?: CustomerOptionRow[]; rows?: CustomerOptionRow[] }) || {}
|
||||
return payload.list || payload.rows || []
|
||||
}
|
||||
|
||||
function ensureCustomerOption(index: number, customer?: Partial<CustomerOptionRow> | null) {
|
||||
if (!customer?.id) return
|
||||
const id = String(customer.id)
|
||||
const list = customerOptionsByIndex.value[index] || []
|
||||
const existing = list.find((item) => String(item.id) === id)
|
||||
if (existing) {
|
||||
if (!customer.customerName) return
|
||||
customerOptionsByIndex.value = {
|
||||
...customerOptionsByIndex.value,
|
||||
[index]: list.map((item) =>
|
||||
String(item.id) === id
|
||||
? {
|
||||
...item,
|
||||
customerName: customer.customerName || item.customerName,
|
||||
customerNo: customer.customerNo || item.customerNo
|
||||
}
|
||||
: item
|
||||
)
|
||||
}
|
||||
return
|
||||
}
|
||||
customerOptionsByIndex.value = {
|
||||
...customerOptionsByIndex.value,
|
||||
[index]: [
|
||||
{ id, customerName: customer.customerName || '', customerNo: customer.customerNo },
|
||||
...list
|
||||
]
|
||||
}
|
||||
}
|
||||
|
||||
watch(
|
||||
() => props.modelValue.map((row) => [row.customerId, row.customerName] as const),
|
||||
(rows) => {
|
||||
rows.forEach((pair, index) => {
|
||||
const [customerId, customerName] = pair
|
||||
if (!customerId) return
|
||||
ensureCustomerOption(index, {
|
||||
id: String(customerId),
|
||||
customerName: customerName || ''
|
||||
})
|
||||
})
|
||||
},
|
||||
{ immediate: true, deep: true }
|
||||
)
|
||||
|
||||
async function loadDefaultCustomerOptions(
|
||||
index: number,
|
||||
customerId?: string,
|
||||
customerName?: string
|
||||
) {
|
||||
customerOptionsLoading.value = { ...customerOptionsLoading.value, [index]: true }
|
||||
try {
|
||||
const res = await fetchCustomerOptions({ limit: 20 })
|
||||
customerOptionsByIndex.value = {
|
||||
...customerOptionsByIndex.value,
|
||||
[index]: extractCustomerOptions(res)
|
||||
}
|
||||
ensureCustomerOption(index, { id: customerId, customerName })
|
||||
} finally {
|
||||
customerOptionsLoading.value = { ...customerOptionsLoading.value, [index]: false }
|
||||
}
|
||||
}
|
||||
|
||||
async function searchCustomerOptions(query: string, index: number) {
|
||||
const keyword = query?.trim()
|
||||
const delivery = props.modelValue[index]
|
||||
if (!keyword) {
|
||||
await loadDefaultCustomerOptions(index, delivery?.customerId, delivery?.customerName)
|
||||
return
|
||||
}
|
||||
customerOptionsLoading.value = { ...customerOptionsLoading.value, [index]: true }
|
||||
try {
|
||||
const res = await fetchCustomerOptions({ keyword, limit: 50 })
|
||||
customerOptionsByIndex.value = {
|
||||
...customerOptionsByIndex.value,
|
||||
[index]: extractCustomerOptions(res)
|
||||
}
|
||||
ensureCustomerOption(index, {
|
||||
id: delivery?.customerId,
|
||||
customerName: delivery?.customerName
|
||||
})
|
||||
} finally {
|
||||
customerOptionsLoading.value = { ...customerOptionsLoading.value, [index]: false }
|
||||
}
|
||||
}
|
||||
|
||||
function handleCustomerSelectFocus(index: number) {
|
||||
if (!(customerOptionsByIndex.value[index] || []).length) {
|
||||
const delivery = props.modelValue[index]
|
||||
loadDefaultCustomerOptions(index, delivery?.customerId, delivery?.customerName)
|
||||
}
|
||||
}
|
||||
|
||||
function handleCustomerChange(index: number, customerId?: string) {
|
||||
if (!customerId) {
|
||||
patchDelivery(index, {
|
||||
customerId: '',
|
||||
customerName: '',
|
||||
contracts: [],
|
||||
generateDibang: 0,
|
||||
dibangDirection: 'none',
|
||||
address: '',
|
||||
lng: null,
|
||||
lat: null,
|
||||
contact: '',
|
||||
notes: ''
|
||||
})
|
||||
return
|
||||
}
|
||||
const current = props.modelValue[index]
|
||||
if (current && String(current.customerId) === String(customerId)) {
|
||||
ensureCustomerOption(index, { id: customerId, customerName: current.customerName })
|
||||
return
|
||||
}
|
||||
const customer = (customerOptionsByIndex.value[index] || []).find(
|
||||
(item) => String(item.id) === String(customerId)
|
||||
)
|
||||
const customerName = customer?.customerName || ''
|
||||
patchDelivery(index, {
|
||||
customerId: String(customerId),
|
||||
customerName,
|
||||
contracts: [],
|
||||
address: '',
|
||||
lng: null,
|
||||
lat: null,
|
||||
contact: '',
|
||||
notes: ''
|
||||
})
|
||||
void applyDeliveryStopPref(index, String(customerId))
|
||||
}
|
||||
|
||||
async function applyDeliveryStopPref(index: number, customerId: string) {
|
||||
try {
|
||||
const res = await customerStopPrefApi.get({ customerId, stopType: 'delivery' })
|
||||
const pref = pickBxData<CustomerStopPref | null>(res)
|
||||
if (!pref) return
|
||||
const current = props.modelValue[index]
|
||||
if (!current || String(current.customerId) !== String(customerId)) return
|
||||
const partial: Partial<PlanDeliveryForm> = {}
|
||||
const prefAddress = (pref.address || '').trim()
|
||||
if (prefAddress) partial.address = prefAddress
|
||||
if (pref.lng != null) partial.lng = pref.lng
|
||||
if (pref.lat != null) partial.lat = pref.lat
|
||||
const prefContact = (pref.contact || '').trim()
|
||||
if (prefContact) partial.contact = prefContact
|
||||
const prefNotes = (pref.notes || '').trim()
|
||||
if (prefNotes) partial.notes = prefNotes
|
||||
if (Object.keys(partial).length) patchDelivery(index, partial)
|
||||
} catch {
|
||||
// 静默:不阻断选客户
|
||||
}
|
||||
}
|
||||
|
||||
function handleDibangToggle(index: number, checked: boolean) {
|
||||
const delivery = props.modelValue[index]
|
||||
const direction = isDibangLocked.value ? 'inbound' : delivery.dibangDirection || 'none'
|
||||
patchDelivery(index, {
|
||||
generateDibang: checked ? 1 : 0,
|
||||
dibangDirection: checked ? direction : 'none'
|
||||
})
|
||||
}
|
||||
|
||||
function applyCustomerFromPicker(
|
||||
index: number,
|
||||
customer: { id: string | number; customerName?: string }
|
||||
) {
|
||||
ensureCustomerOption(index, { id: String(customer.id), customerName: customer.customerName })
|
||||
handleCustomerChange(index, String(customer.id))
|
||||
}
|
||||
|
||||
defineExpose({
|
||||
applyCustomerFromPicker,
|
||||
ensureCustomerOption,
|
||||
loadDefaultCustomerOptions,
|
||||
addDelivery,
|
||||
moveDelivery,
|
||||
removeDelivery
|
||||
})
|
||||
</script>
|
||||
|
||||
<style scoped lang="scss">
|
||||
.pl-plan-delivery-section__toolbar {
|
||||
margin-bottom: 8px;
|
||||
}
|
||||
|
||||
.pl-plan-delivery-section__hint {
|
||||
margin: 0;
|
||||
font-size: 12px;
|
||||
color: #64748b;
|
||||
}
|
||||
|
||||
.pl-plan-delivery-tabs {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
gap: 4px;
|
||||
margin-bottom: 8px;
|
||||
}
|
||||
|
||||
.pl-plan-delivery-tab {
|
||||
border: 1px solid #d9e8e2;
|
||||
background: #fff;
|
||||
border-radius: 6px;
|
||||
padding: 5px 10px;
|
||||
font-size: 11px;
|
||||
font-weight: 600;
|
||||
cursor: pointer;
|
||||
color: #64748b;
|
||||
font-family: inherit;
|
||||
max-width: 100%;
|
||||
text-align: left;
|
||||
line-height: 1.35;
|
||||
|
||||
&.is-active {
|
||||
border-color: #7dd3fc;
|
||||
background: #f0f9ff;
|
||||
color: #0284c7;
|
||||
}
|
||||
|
||||
&__qty {
|
||||
margin-left: 4px;
|
||||
font-weight: 400;
|
||||
color: #94a3b8;
|
||||
}
|
||||
}
|
||||
|
||||
.pl-plan-delivery-card {
|
||||
&.is-tab-panel {
|
||||
border: none;
|
||||
padding: 0;
|
||||
margin: 0;
|
||||
background: transparent;
|
||||
}
|
||||
|
||||
&:not(.is-tab-panel) {
|
||||
border: 1px solid #d9e8e2;
|
||||
border-radius: 10px;
|
||||
padding: 14px;
|
||||
margin-bottom: 12px;
|
||||
background: #fff;
|
||||
}
|
||||
}
|
||||
|
||||
.pl-plan-delivery-card__head {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
gap: 12px;
|
||||
margin-bottom: 10px;
|
||||
}
|
||||
|
||||
.pl-plan-delivery-card__title {
|
||||
margin: 0;
|
||||
font-size: 13px;
|
||||
font-weight: 600;
|
||||
color: #1e293b;
|
||||
}
|
||||
|
||||
.pl-plan-delivery-card__actions {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 8px;
|
||||
}
|
||||
|
||||
.pl-plan-stop-products-head {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
gap: 12px;
|
||||
margin: 8px 0 0;
|
||||
}
|
||||
|
||||
.pl-plan-stop-products-head__title {
|
||||
font-size: 12px;
|
||||
font-weight: 600;
|
||||
color: #64748b;
|
||||
}
|
||||
|
||||
.pl-plan-delivery-section__split-hint {
|
||||
margin: 6px 0 0;
|
||||
font-size: 12px;
|
||||
color: #d97706;
|
||||
}
|
||||
|
||||
.pl-plan-delivery-section__empty-hint {
|
||||
margin: 6px 0 0;
|
||||
font-size: 12px;
|
||||
color: #94a3b8;
|
||||
}
|
||||
|
||||
.pl-plan-dibang-row {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
flex-wrap: wrap;
|
||||
gap: 12px;
|
||||
}
|
||||
|
||||
.pl-plan-dibang-row__hint {
|
||||
font-size: 12px;
|
||||
color: #64748b;
|
||||
}
|
||||
|
||||
.customer-select-row {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 4px;
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.customer-select-row__select {
|
||||
flex: 1 1 auto;
|
||||
min-width: 0;
|
||||
}
|
||||
|
||||
.pl-plan-party-select-row {
|
||||
display: flex;
|
||||
flex-direction: row;
|
||||
align-items: flex-start;
|
||||
gap: 12px;
|
||||
margin-bottom: 8px;
|
||||
}
|
||||
|
||||
.pl-plan-party-select-row__customer {
|
||||
flex: 1.4 1 0;
|
||||
min-width: 0;
|
||||
margin-bottom: 0 !important;
|
||||
}
|
||||
|
||||
.pl-plan-party-select-row__contract {
|
||||
flex: 1 1 0;
|
||||
min-width: 120px;
|
||||
margin-bottom: 0 !important;
|
||||
}
|
||||
|
||||
.pl-plan-contract-trigger {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
flex-wrap: wrap;
|
||||
gap: 8px;
|
||||
min-height: 32px;
|
||||
}
|
||||
|
||||
.pl-plan-contract-trigger__hint {
|
||||
font-size: 12px;
|
||||
color: #64748b;
|
||||
|
||||
&.is-warn {
|
||||
color: #d97706;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
@@ -12,8 +12,32 @@
|
||||
:title="item.isImage || item.isPdf ? '点击在新标签页查看' : '点击查看'"
|
||||
@click.stop="handlePreview(item)"
|
||||
>
|
||||
<div class="pl-plan-document-attachment-cell__placeholder is-clickable">
|
||||
<el-icon :size="16" color="#10b981"><Picture /></el-icon>
|
||||
<el-image
|
||||
v-if="item.isImage && !usePlaceholderThumb && mediaActive"
|
||||
class="pl-plan-document-attachment-cell__image pl-plan-document-attachment-cell__image--passive"
|
||||
fit="cover"
|
||||
lazy
|
||||
:src="displaySrc(item.url)"
|
||||
:preview-src-list="[]"
|
||||
>
|
||||
<template #error>
|
||||
<div class="pl-plan-document-attachment-cell__placeholder is-clickable is-common-thumb">
|
||||
<el-icon :size="16" color="#10b981"><Picture /></el-icon>
|
||||
</div>
|
||||
</template>
|
||||
</el-image>
|
||||
<div
|
||||
v-else
|
||||
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'">
|
||||
<Picture v-if="usePlaceholderThumb || item.isImage" />
|
||||
<Document v-else />
|
||||
</el-icon>
|
||||
<span v-if="!usePlaceholderThumb && item.ext" class="pl-plan-document-attachment-cell__ext">{{
|
||||
item.ext
|
||||
}}</span>
|
||||
</div>
|
||||
</div>
|
||||
<el-icon
|
||||
@@ -32,7 +56,7 @@
|
||||
|
||||
<script setup lang="ts">
|
||||
import { computed } from 'vue'
|
||||
import { Download, Picture } from '@element-plus/icons-vue'
|
||||
import { Document, Download, Picture } from '@element-plus/icons-vue'
|
||||
import { ElMessage } from 'element-plus'
|
||||
import type { PlanDocumentAttachmentItem } from '@/api/pl'
|
||||
import {
|
||||
@@ -44,11 +68,15 @@
|
||||
const props = withDefaults(
|
||||
defineProps<{
|
||||
attachments?: PlanDocumentAttachmentItem[] | null
|
||||
/** KeepAlive 离开页时置 false,暂停缩略图请求 */
|
||||
mediaActive?: boolean
|
||||
/** 列表态仅用统一占位缩略图,点击预览/下载时再加载真实文件 */
|
||||
usePlaceholderThumb?: boolean
|
||||
}>(),
|
||||
{
|
||||
attachments: () => [],
|
||||
mediaActive: true
|
||||
mediaActive: true,
|
||||
usePlaceholderThumb: true
|
||||
}
|
||||
)
|
||||
|
||||
@@ -59,6 +87,7 @@
|
||||
url: string
|
||||
isImage: boolean
|
||||
isPdf: boolean
|
||||
ext: string
|
||||
}
|
||||
|
||||
function isImageUrl(url: string) {
|
||||
@@ -75,6 +104,14 @@
|
||||
return /\.pdf$/i.test(path)
|
||||
}
|
||||
|
||||
function fileExt(url: string) {
|
||||
const path = String(url || '')
|
||||
.split('?')[0]
|
||||
.toLowerCase()
|
||||
const match = path.match(/\.([a-z0-9]+)$/i)
|
||||
return match ? match[1].toUpperCase() : ''
|
||||
}
|
||||
|
||||
function fileNameFromUrl(url: string) {
|
||||
return (
|
||||
String(url || '')
|
||||
@@ -84,6 +121,10 @@
|
||||
)
|
||||
}
|
||||
|
||||
function displaySrc(url: string) {
|
||||
return resolvePhotoDisplayUrl(url) || url
|
||||
}
|
||||
|
||||
async function handlePreview(item: ItemDef) {
|
||||
if (!item.url) return
|
||||
await openAttachmentPreviewInNewTab(
|
||||
@@ -125,7 +166,8 @@
|
||||
fullLabel,
|
||||
url,
|
||||
isImage: isImageUrl(url),
|
||||
isPdf: isPdfUrl(url)
|
||||
isPdf: isPdfUrl(url),
|
||||
ext: fileExt(url)
|
||||
}
|
||||
})
|
||||
})
|
||||
@@ -165,18 +207,39 @@
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.pl-plan-document-attachment-cell__image {
|
||||
display: block;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
|
||||
&--passive {
|
||||
pointer-events: none;
|
||||
}
|
||||
}
|
||||
|
||||
.pl-plan-document-attachment-cell__placeholder {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
margin-bottom: 10px;
|
||||
background: var(--primary-bg, #ecfdf5);
|
||||
|
||||
&.is-clickable {
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
&.is-common-thumb {
|
||||
background: var(--primary-bg, #ecfdf5);
|
||||
}
|
||||
}
|
||||
|
||||
.pl-plan-document-attachment-cell__ext {
|
||||
margin-top: 2px;
|
||||
font-size: 9px;
|
||||
line-height: 1;
|
||||
color: #64748b;
|
||||
}
|
||||
|
||||
.pl-plan-document-attachment-cell__download {
|
||||
|
||||
@@ -126,8 +126,8 @@
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column
|
||||
v-if="showInboundOutboundQty || showArchiveIoFields"
|
||||
label="入库数量"
|
||||
v-if="(showInboundOutboundQty || showArchiveIoFields) && !archiveIoOutboundOnly"
|
||||
:label="archiveSegmentLabels ? '实际数量' : '入库数量'"
|
||||
min-width="110"
|
||||
align="right"
|
||||
>
|
||||
@@ -144,8 +144,8 @@
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column
|
||||
v-if="showArchiveIoFields"
|
||||
label="入库单价(元)"
|
||||
v-if="showArchiveIoFields && !archiveIoOutboundOnly"
|
||||
:label="archiveSegmentLabels ? '单价(元)' : '入库单价(元)'"
|
||||
min-width="120"
|
||||
align="right"
|
||||
>
|
||||
@@ -162,8 +162,8 @@
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column
|
||||
v-if="showArchiveIoFields"
|
||||
label="入库金额"
|
||||
v-if="showArchiveIoFields && !archiveIoOutboundOnly"
|
||||
:label="archiveSegmentLabels ? '金额(元)' : '入库金额'"
|
||||
min-width="110"
|
||||
align="right"
|
||||
>
|
||||
@@ -172,8 +172,8 @@
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column
|
||||
v-if="showInboundOutboundQty || showArchiveIoFields"
|
||||
label="出库数量"
|
||||
v-if="(showInboundOutboundQty || showArchiveIoFields) && !archiveIoInboundOnly"
|
||||
:label="archiveSegmentLabels ? '实际数量' : '出库数量'"
|
||||
min-width="110"
|
||||
align="right"
|
||||
>
|
||||
@@ -190,8 +190,8 @@
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column
|
||||
v-if="showArchiveIoFields"
|
||||
label="出库单价(元)"
|
||||
v-if="showArchiveIoFields && !archiveIoInboundOnly"
|
||||
:label="archiveSegmentLabels ? '单价(元)' : '出库单价(元)'"
|
||||
min-width="120"
|
||||
align="right"
|
||||
>
|
||||
@@ -208,8 +208,8 @@
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column
|
||||
v-if="showArchiveIoFields"
|
||||
label="出库金额"
|
||||
v-if="showArchiveIoFields && !archiveIoInboundOnly"
|
||||
:label="archiveSegmentLabels ? '金额(元)' : '出库金额'"
|
||||
min-width="110"
|
||||
align="right"
|
||||
>
|
||||
@@ -348,6 +348,12 @@ const props = defineProps<{
|
||||
showArchiveIoFields?: boolean
|
||||
/** 入库/出库数量与价格可编辑(归档弹窗) */
|
||||
editableArchiveIoFields?: boolean
|
||||
/** 归档:仅展示/编辑入库列(装货段) */
|
||||
archiveIoInboundOnly?: boolean
|
||||
/** 归档:仅展示/编辑出库列(送货段) */
|
||||
archiveIoOutboundOnly?: boolean
|
||||
/** 段次归档:入库/出库列统一展示为实际数量、单价、金额 */
|
||||
archiveSegmentLabels?: boolean
|
||||
}>()
|
||||
|
||||
const emit = defineEmits<{
|
||||
|
||||
File diff suppressed because it is too large.
Load diff
@@ -1,7 +1,7 @@
|
||||
<template>
|
||||
<div v-if="products.length" class="pl-plan-list-product-cell">
|
||||
<div v-if="displayProducts.length" class="pl-plan-list-product-cell">
|
||||
<div
|
||||
v-for="(product, index) in products"
|
||||
v-for="(product, index) in displayProducts"
|
||||
:key="product.id || `${product.productNo}-${index}`"
|
||||
class="pl-plan-list-product-cell__row"
|
||||
>
|
||||
@@ -19,7 +19,11 @@
|
||||
}"
|
||||
>
|
||||
<template v-if="!field">
|
||||
<span class="pl-plan-list-product-cell__text">{{ formatProductLine(product) }}</span>
|
||||
<span class="pl-plan-list-product-cell__text">{{
|
||||
useStopProducts
|
||||
? formatStopProductLine(product as PlanStopProduct)
|
||||
: formatProductLine(product as PlanProduct)
|
||||
}}</span>
|
||||
<el-tag
|
||||
v-if="getHazardFlags(product).isToxic"
|
||||
type="warning"
|
||||
@@ -37,22 +41,24 @@
|
||||
爆
|
||||
</el-tag>
|
||||
<span
|
||||
v-if="showCertStatus && isHazardProduct(product)"
|
||||
v-if="showCertStatus && isHazardProduct(resolveCertProduct(product))"
|
||||
class="pl-plan-list-product-cell__certs"
|
||||
>
|
||||
<span
|
||||
v-for="slot in getRequiredCertSlots(product)"
|
||||
v-for="slot in getRequiredCertSlots(resolveCertProduct(product))"
|
||||
:key="slot.key"
|
||||
class="pl-plan-list-product-cell__cert-text"
|
||||
>
|
||||
{{ slot.label }}(<span
|
||||
:class="{
|
||||
'pl-plan-list-product-cell__cert-status--missing': !isProductCertSlotFilled(
|
||||
product,
|
||||
resolveCertProduct(product),
|
||||
slot.key
|
||||
)
|
||||
}"
|
||||
>{{ isProductCertSlotFilled(product, slot.key) ? '有' : '无' }}</span
|
||||
>{{
|
||||
isProductCertSlotFilled(resolveCertProduct(product), slot.key) ? '有' : '无'
|
||||
}}</span
|
||||
>)
|
||||
</span>
|
||||
</span>
|
||||
@@ -84,174 +90,276 @@
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import type { PlanProduct } from '@/api/pl'
|
||||
import {
|
||||
getRequiredCertSlots,
|
||||
isHazardProduct,
|
||||
isProductCertSlotFilled,
|
||||
resolveProductHazardFlags
|
||||
} from '@/composables/usePlToxicProductCertCheck'
|
||||
import { useDictStore } from '@/store/modules/dict'
|
||||
import {
|
||||
formatPlanProductListText,
|
||||
getPlanProductActualQuantity,
|
||||
getPlanProductInboundQuantity,
|
||||
getPlanProductModel,
|
||||
getPlanProductOutboundQuantity,
|
||||
getPlanProductPackageSpec,
|
||||
getPlanProductPlannedQuantity,
|
||||
getPlanProductQuantity,
|
||||
getPlanProductSpec
|
||||
} from '@/utils/pl-display'
|
||||
import type { PlanProduct, PlanStopProduct } from '@/api/pl'
|
||||
import {
|
||||
getRequiredCertSlots,
|
||||
isHazardProduct,
|
||||
isProductCertSlotFilled,
|
||||
resolveProductHazardFlags
|
||||
} from '@/composables/usePlToxicProductCertCheck'
|
||||
import { useDictStore } from '@/store/modules/dict'
|
||||
import {
|
||||
formatPlanProductListText,
|
||||
getPlanProductActualQuantity,
|
||||
getPlanProductInboundQuantity,
|
||||
getPlanProductModel,
|
||||
getPlanProductOutboundQuantity,
|
||||
getPlanProductPackageSpec,
|
||||
getPlanProductPlannedQuantity,
|
||||
getPlanProductQuantity,
|
||||
getPlanProductSpec
|
||||
} from '@/utils/pl-display'
|
||||
import { computed } from 'vue'
|
||||
|
||||
export type PlPlanListProductCellField =
|
||||
| 'name'
|
||||
| 'spec'
|
||||
| 'model'
|
||||
| 'packageSpec'
|
||||
| 'qty'
|
||||
| 'planQty'
|
||||
| 'actualQty'
|
||||
| 'inboundQty'
|
||||
| 'outboundQty'
|
||||
| 'unit'
|
||||
export type PlPlanListProductCellField =
|
||||
| 'name'
|
||||
| 'spec'
|
||||
| 'model'
|
||||
| 'packageSpec'
|
||||
| 'qty'
|
||||
| 'planQty'
|
||||
| 'actualQty'
|
||||
| 'inboundQty'
|
||||
| 'outboundQty'
|
||||
| 'unit'
|
||||
|
||||
const props = withDefaults(
|
||||
defineProps<{
|
||||
products?: PlanProduct[]
|
||||
/** 按字段拆列展示;未传时保持整行拼接 */
|
||||
field?: PlPlanListProductCellField
|
||||
/** 危化品行下方展示证书有无(按产品类型;仅整行模式) */
|
||||
showCertStatus?: boolean
|
||||
}>(),
|
||||
{
|
||||
products: () => [],
|
||||
showCertStatus: false
|
||||
}
|
||||
)
|
||||
const props = withDefaults(
|
||||
defineProps<{
|
||||
products?: PlanProduct[]
|
||||
/** 段内产品(与 products 二选一,优先 stopProducts) */
|
||||
stopProducts?: PlanStopProduct[]
|
||||
/** 关联计划产品,用于段内 actualQty 与危化标识 */
|
||||
planProducts?: PlanProduct[]
|
||||
/** 按字段拆列展示;未传时保持整行拼接 */
|
||||
field?: PlPlanListProductCellField
|
||||
/** 危化品行下方展示证书有无(按产品类型;仅整行模式) */
|
||||
showCertStatus?: boolean
|
||||
}>(),
|
||||
{
|
||||
products: () => [],
|
||||
stopProducts: () => [],
|
||||
planProducts: () => [],
|
||||
showCertStatus: false
|
||||
}
|
||||
)
|
||||
|
||||
const dictStore = useDictStore()
|
||||
const dictStore = useDictStore()
|
||||
|
||||
function getUnitLabel(unit: string) {
|
||||
return dictStore.getLabel('crm_product_unit', unit)
|
||||
}
|
||||
const useStopProducts = computed(() => (props.stopProducts?.length ?? 0) > 0)
|
||||
|
||||
function formatProductLine(product: PlanProduct) {
|
||||
return formatPlanProductListText(product, getUnitLabel)
|
||||
}
|
||||
const displayProducts = computed(() => {
|
||||
if (useStopProducts.value) return props.stopProducts
|
||||
return props.products
|
||||
})
|
||||
|
||||
function formatFieldValue(product: PlanProduct) {
|
||||
if (props.field === 'spec') {
|
||||
return getPlanProductSpec(product)
|
||||
function getUnitLabel(unit: string) {
|
||||
return dictStore.getLabel('crm_product_unit', unit)
|
||||
}
|
||||
if (props.field === 'model') {
|
||||
return getPlanProductModel(product)
|
||||
}
|
||||
if (props.field === 'packageSpec') {
|
||||
return getPlanProductPackageSpec(product)
|
||||
}
|
||||
if (props.field === 'qty') {
|
||||
return getPlanProductQuantity(product)
|
||||
}
|
||||
if (props.field === 'planQty') {
|
||||
return getPlanProductPlannedQuantity(product)
|
||||
}
|
||||
if (props.field === 'actualQty') {
|
||||
return getPlanProductActualQuantity(product)
|
||||
}
|
||||
if (props.field === 'inboundQty') {
|
||||
return getPlanProductInboundQuantity(product)
|
||||
}
|
||||
if (props.field === 'outboundQty') {
|
||||
return getPlanProductOutboundQuantity(product)
|
||||
}
|
||||
if (props.field === 'unit') {
|
||||
const unitRaw = product.unit || ''
|
||||
if (!unitRaw) return '—'
|
||||
return getUnitLabel(unitRaw) || unitRaw
|
||||
}
|
||||
return '—'
|
||||
}
|
||||
|
||||
function getHazardFlags(product: PlanProduct) {
|
||||
return resolveProductHazardFlags(product)
|
||||
}
|
||||
function resolveLinkedPlanProduct(stopProduct: PlanStopProduct): PlanProduct | undefined {
|
||||
const planProducts = props.planProducts || []
|
||||
return (
|
||||
planProducts.find(
|
||||
(item) =>
|
||||
stopProduct.planProductId &&
|
||||
item.id &&
|
||||
String(item.id) === String(stopProduct.planProductId)
|
||||
) || planProducts.find((item) => String(item.productId) === String(stopProduct.productId))
|
||||
)
|
||||
}
|
||||
|
||||
function formatStopProductLine(stopProduct: PlanStopProduct) {
|
||||
const linked = resolveLinkedPlanProduct(stopProduct)
|
||||
if (linked) return formatPlanProductListText(linked, getUnitLabel)
|
||||
const unit = getUnitLabel(stopProduct.unit || '') || stopProduct.unit || ''
|
||||
const qty =
|
||||
stopProduct.planQty != null && Number.isFinite(Number(stopProduct.planQty))
|
||||
? `${stopProduct.planQty}${unit ? ` ${unit}` : ''}`
|
||||
: ''
|
||||
const model = stopProduct.model ? ` ${stopProduct.model}` : ''
|
||||
return [stopProduct.productName || '—', model, qty].filter(Boolean).join('')
|
||||
}
|
||||
|
||||
function formatStopQty(value: unknown, unitRaw?: string) {
|
||||
if (value == null || value === '') return '—'
|
||||
const num = Number(value)
|
||||
if (!Number.isFinite(num)) return '—'
|
||||
const unit = getUnitLabel(unitRaw || '') || unitRaw || ''
|
||||
return unit ? `${num} ${unit}` : String(num)
|
||||
}
|
||||
|
||||
function formatProductLine(product: PlanProduct) {
|
||||
return formatPlanProductListText(product, getUnitLabel)
|
||||
}
|
||||
|
||||
function formatFieldValue(product: PlanProduct | PlanStopProduct) {
|
||||
if (useStopProducts.value) {
|
||||
const stopProduct = product as PlanStopProduct
|
||||
const linked = resolveLinkedPlanProduct(stopProduct)
|
||||
if (props.field === 'spec' || props.field === 'model') {
|
||||
return (
|
||||
stopProduct.model || linked?.model || (linked ? getPlanProductSpec(linked) : '—') || '—'
|
||||
)
|
||||
}
|
||||
if (props.field === 'packageSpec') {
|
||||
return stopProduct.packageSpec || linked?.packageSpec || '—'
|
||||
}
|
||||
if (props.field === 'planQty') {
|
||||
return formatStopQty(stopProduct.planQty)
|
||||
}
|
||||
if (props.field === 'inboundQty') {
|
||||
return formatStopQty(stopProduct.inboundQty, stopProduct.unit)
|
||||
}
|
||||
if (props.field === 'outboundQty') {
|
||||
return formatStopQty(stopProduct.outboundQty, stopProduct.unit)
|
||||
}
|
||||
if (props.field === 'actualQty') {
|
||||
return linked ? getPlanProductActualQuantity(linked) : '—'
|
||||
}
|
||||
if (props.field === 'unit') {
|
||||
const unitRaw = stopProduct.unit || linked?.unit || ''
|
||||
if (!unitRaw) return '—'
|
||||
return getUnitLabel(unitRaw) || unitRaw
|
||||
}
|
||||
return '—'
|
||||
}
|
||||
|
||||
const planProduct = product as PlanProduct
|
||||
if (props.field === 'spec') {
|
||||
return getPlanProductSpec(planProduct)
|
||||
}
|
||||
if (props.field === 'model') {
|
||||
return getPlanProductModel(planProduct)
|
||||
}
|
||||
if (props.field === 'packageSpec') {
|
||||
return getPlanProductPackageSpec(planProduct)
|
||||
}
|
||||
if (props.field === 'qty') {
|
||||
return getPlanProductQuantity(planProduct)
|
||||
}
|
||||
if (props.field === 'planQty') {
|
||||
return getPlanProductPlannedQuantity(planProduct)
|
||||
}
|
||||
if (props.field === 'actualQty') {
|
||||
return getPlanProductActualQuantity(planProduct)
|
||||
}
|
||||
if (props.field === 'inboundQty') {
|
||||
return getPlanProductInboundQuantity(planProduct)
|
||||
}
|
||||
if (props.field === 'outboundQty') {
|
||||
return getPlanProductOutboundQuantity(planProduct)
|
||||
}
|
||||
if (props.field === 'unit') {
|
||||
const unitRaw = planProduct.unit || ''
|
||||
if (!unitRaw) return '—'
|
||||
return getUnitLabel(unitRaw) || unitRaw
|
||||
}
|
||||
return '—'
|
||||
}
|
||||
|
||||
function getHazardFlags(product: PlanProduct | PlanStopProduct) {
|
||||
if (useStopProducts.value) {
|
||||
const linked = resolveLinkedPlanProduct(product as PlanStopProduct)
|
||||
if (linked) return resolveProductHazardFlags(linked)
|
||||
return { isToxic: false, isExplosive: false }
|
||||
}
|
||||
return resolveProductHazardFlags(product as PlanProduct)
|
||||
}
|
||||
|
||||
function resolveCertProduct(product: PlanProduct | PlanStopProduct): PlanProduct {
|
||||
if (useStopProducts.value) {
|
||||
return (
|
||||
resolveLinkedPlanProduct(product as PlanStopProduct) ||
|
||||
({
|
||||
id: (product as PlanStopProduct).id || (product as PlanStopProduct).productId,
|
||||
planId: '',
|
||||
productId: (product as PlanStopProduct).productId,
|
||||
productNo: (product as PlanStopProduct).productNo,
|
||||
productName: (product as PlanStopProduct).productName,
|
||||
unit: (product as PlanStopProduct).unit || '吨',
|
||||
isExplosive: 0,
|
||||
isToxic: 0
|
||||
} as PlanProduct)
|
||||
)
|
||||
}
|
||||
return product as PlanProduct
|
||||
}
|
||||
</script>
|
||||
|
||||
<style scoped lang="scss">
|
||||
.pl-plan-list-product-cell {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: flex-start;
|
||||
gap: 8px;
|
||||
width: 100%;
|
||||
text-align: left;
|
||||
}
|
||||
.pl-plan-list-product-cell {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: flex-start;
|
||||
gap: 8px;
|
||||
width: 100%;
|
||||
text-align: left;
|
||||
}
|
||||
|
||||
.pl-plan-list-product-cell__row {
|
||||
width: 100%;
|
||||
min-width: 0;
|
||||
}
|
||||
.pl-plan-list-product-cell__row {
|
||||
width: 100%;
|
||||
min-width: 0;
|
||||
}
|
||||
|
||||
.pl-plan-list-product-cell__line {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: flex-start;
|
||||
flex-wrap: wrap;
|
||||
gap: 4px;
|
||||
flex: 1;
|
||||
min-width: 0;
|
||||
font-size: 13px;
|
||||
line-height: 1.5;
|
||||
color: var(--text, #1e293b);
|
||||
text-align: left;
|
||||
}
|
||||
.pl-plan-list-product-cell__line {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: flex-start;
|
||||
flex-wrap: wrap;
|
||||
gap: 4px;
|
||||
flex: 1;
|
||||
min-width: 0;
|
||||
font-size: 13px;
|
||||
line-height: 1.5;
|
||||
color: var(--text, #1e293b);
|
||||
text-align: left;
|
||||
}
|
||||
|
||||
.pl-plan-list-product-cell__line--qty {
|
||||
justify-content: flex-end;
|
||||
text-align: right;
|
||||
width: 100%;
|
||||
}
|
||||
.pl-plan-list-product-cell__line--qty {
|
||||
justify-content: flex-end;
|
||||
text-align: right;
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.pl-plan-list-product-cell__line--center {
|
||||
justify-content: center;
|
||||
text-align: center;
|
||||
width: 100%;
|
||||
}
|
||||
.pl-plan-list-product-cell__line--center {
|
||||
justify-content: center;
|
||||
text-align: center;
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.pl-plan-list-product-cell__text {
|
||||
min-width: 0;
|
||||
white-space: normal;
|
||||
word-break: break-word;
|
||||
overflow-wrap: anywhere;
|
||||
}
|
||||
.pl-plan-list-product-cell__text {
|
||||
min-width: 0;
|
||||
white-space: normal;
|
||||
word-break: break-word;
|
||||
overflow-wrap: anywhere;
|
||||
}
|
||||
|
||||
.pl-plan-list-product-cell__mark {
|
||||
flex-shrink: 0;
|
||||
font-weight: 600;
|
||||
}
|
||||
.pl-plan-list-product-cell__mark {
|
||||
flex-shrink: 0;
|
||||
font-weight: 600;
|
||||
}
|
||||
|
||||
.pl-plan-list-product-cell__certs {
|
||||
display: inline-flex;
|
||||
flex-wrap: wrap;
|
||||
align-items: center;
|
||||
gap: 8px;
|
||||
margin-left: 4px;
|
||||
}
|
||||
.pl-plan-list-product-cell__certs {
|
||||
display: inline-flex;
|
||||
flex-wrap: wrap;
|
||||
align-items: center;
|
||||
gap: 8px;
|
||||
margin-left: 4px;
|
||||
}
|
||||
|
||||
.pl-plan-list-product-cell__cert-text {
|
||||
color: var(--mint-text);
|
||||
font-size: 12px;
|
||||
line-height: 1.4;
|
||||
white-space: nowrap;
|
||||
}
|
||||
.pl-plan-list-product-cell__cert-text {
|
||||
color: var(--mint-text);
|
||||
font-size: 12px;
|
||||
line-height: 1.4;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
.pl-plan-list-product-cell__cert-status--missing {
|
||||
color: var(--danger, #dc2626);
|
||||
font-weight: 500;
|
||||
}
|
||||
.pl-plan-list-product-cell__cert-status--missing {
|
||||
color: var(--danger, #dc2626);
|
||||
font-weight: 500;
|
||||
}
|
||||
|
||||
.pl-plan-list-product-cell__empty {
|
||||
color: var(--mint-text);
|
||||
}
|
||||
.pl-plan-list-product-cell__empty {
|
||||
color: var(--mint-text);
|
||||
}
|
||||
</style>
|
||||
@@ -0,0 +1,481 @@
|
||||
<!-- eslint-disable vue/no-v-model-argument -->
|
||||
<template>
|
||||
<div class="pl-plan-load-section">
|
||||
<PlPlanContractMultiSelect
|
||||
v-model="contractsModel"
|
||||
:customer-id="modelValue.customerId"
|
||||
:disabled="!modelValue.customerId || contractDisabled"
|
||||
:required="false"
|
||||
compact-summary
|
||||
>
|
||||
<template #toolbar="{ open, disabled, hint, hintWarn }">
|
||||
<div class="pl-plan-party-select-row">
|
||||
<el-form-item label="装货客户" required class="pl-plan-party-select-row__customer">
|
||||
<div class="customer-select-row">
|
||||
<el-select
|
||||
:model-value="modelValue.customerId"
|
||||
class="customer-select-row__select"
|
||||
filterable
|
||||
remote
|
||||
clearable
|
||||
:remote-method="searchCustomerOptions"
|
||||
:loading="customerOptionsLoading"
|
||||
placeholder="客户名称/拼音首字母"
|
||||
@focus="handleCustomerSelectFocus"
|
||||
@update:model-value="handleCustomerChange"
|
||||
>
|
||||
<el-option
|
||||
v-for="item in customerOptions"
|
||||
:key="item.id"
|
||||
:label="item.customerName"
|
||||
:value="item.id"
|
||||
>
|
||||
<div class="customer-option-row">
|
||||
<span>{{ item.customerName }}</span>
|
||||
<span v-if="item.customerNo" class="customer-option-row__meta">{{
|
||||
item.customerNo
|
||||
}}</span>
|
||||
</div>
|
||||
</el-option>
|
||||
</el-select>
|
||||
<el-button
|
||||
text
|
||||
class="customer-select-row__search"
|
||||
@click="emit('open-customer-picker')"
|
||||
>
|
||||
<el-icon><Search /></el-icon>
|
||||
</el-button>
|
||||
</div>
|
||||
</el-form-item>
|
||||
<el-form-item label="装货合同" class="pl-plan-party-select-row__contract">
|
||||
<div class="pl-plan-contract-trigger">
|
||||
<el-button class="btn-ghost" :disabled="disabled" @click="open">
|
||||
<el-icon><Search /></el-icon>选择合同
|
||||
</el-button>
|
||||
<span
|
||||
v-if="hint"
|
||||
class="pl-plan-contract-trigger__hint"
|
||||
:class="{ 'is-warn': hintWarn }"
|
||||
>
|
||||
{{ hint }}
|
||||
</span>
|
||||
</div>
|
||||
</el-form-item>
|
||||
</div>
|
||||
</template>
|
||||
</PlPlanContractMultiSelect>
|
||||
|
||||
<div class="form-grid-2 pl-plan-load-section__grid">
|
||||
<el-form-item label="装货时间">
|
||||
<el-date-picker
|
||||
:model-value="modelValue.loadTime"
|
||||
type="date"
|
||||
placeholder="选择装货时间"
|
||||
value-format="YYYY-MM-DD"
|
||||
style="width: 100%"
|
||||
@update:model-value="patch({ loadTime: $event || '' })"
|
||||
/>
|
||||
</el-form-item>
|
||||
<el-form-item label="联系方式">
|
||||
<el-input
|
||||
:model-value="modelValue.contact"
|
||||
placeholder="联系方式"
|
||||
@update:model-value="patch({ contact: $event })"
|
||||
/>
|
||||
</el-form-item>
|
||||
<el-form-item label="装货地址" class="form-col-span-2">
|
||||
<PlAddressWithLibrary
|
||||
:model-value="modelValue.address"
|
||||
:lng="modelValue.lng"
|
||||
:lat="modelValue.lat"
|
||||
:contact="modelValue.contact"
|
||||
placeholder="装货地址"
|
||||
@apply="patchAddress($event)"
|
||||
/>
|
||||
</el-form-item>
|
||||
<el-form-item label="注意事项" class="form-col-span-2">
|
||||
<el-input
|
||||
:model-value="modelValue.notes"
|
||||
placeholder="装货注意事项"
|
||||
@update:model-value="patch({ notes: $event })"
|
||||
/>
|
||||
</el-form-item>
|
||||
<el-form-item label="地磅单" class="form-col-span-2">
|
||||
<div class="pl-plan-dibang-row">
|
||||
<el-checkbox
|
||||
:model-value="modelValue.generateDibang === 1"
|
||||
:disabled="isInternal"
|
||||
@update:model-value="handleDibangToggle"
|
||||
>
|
||||
生成地磅单({{ dibangDirectionLabel }})
|
||||
</el-checkbox>
|
||||
<span v-if="isInternal" class="pl-plan-dibang-row__hint">装货客户为内部客户时默认勾选</span>
|
||||
</div>
|
||||
</el-form-item>
|
||||
</div>
|
||||
|
||||
<div class="pl-plan-stop-products-head">
|
||||
<span class="pl-plan-stop-products-head__title">装货产品</span>
|
||||
<el-button
|
||||
v-if="!readonly"
|
||||
class="btn-main"
|
||||
type="primary"
|
||||
size="small"
|
||||
@click="emit('add-products')"
|
||||
>
|
||||
<el-icon><Plus /></el-icon>添加产品
|
||||
</el-button>
|
||||
</div>
|
||||
<p v-if="!modelValue.products.length" class="pl-plan-load-section__empty-hint">
|
||||
请添加至少一条装货产品
|
||||
</p>
|
||||
<PlPlanStopProductTable
|
||||
:products="modelValue.products"
|
||||
:editable="!readonly"
|
||||
:compact="compactProducts"
|
||||
@remove="removeStopProduct"
|
||||
/>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { Plus, Search } from '@element-plus/icons-vue'
|
||||
import { fetchCustomerOptions } from '@/api/crm/customer'
|
||||
import { customerStopPrefApi, type CustomerStopPref } from '@/api/pl/index'
|
||||
import PlAddressWithLibrary, {
|
||||
type PlAddressApplyPayload
|
||||
} from '@/components/business/pl-address-with-library/index.vue'
|
||||
import PlPlanContractMultiSelect from '@/components/business/pl-plan-contract-multi-select/index.vue'
|
||||
import PlPlanStopProductTable from '@/components/business/pl-plan-stop-product-table/index.vue'
|
||||
import { resolveStopDibangDefaults, type PlanLoadForm } from '@/utils/pl-plan-stop-form'
|
||||
import { isPlInternalCustomerName } from '@/utils/pl-internal-customer'
|
||||
import { pickBxData } from '@/utils/http/bx'
|
||||
|
||||
const props = withDefaults(
|
||||
defineProps<{
|
||||
modelValue: PlanLoadForm
|
||||
readonly?: boolean
|
||||
compactProducts?: boolean
|
||||
}>(),
|
||||
{
|
||||
readonly: false,
|
||||
compactProducts: true
|
||||
}
|
||||
)
|
||||
|
||||
const emit = defineEmits<{
|
||||
'update:modelValue': [value: PlanLoadForm]
|
||||
'open-customer-picker': []
|
||||
'add-products': []
|
||||
'customer-conflict': [message: string]
|
||||
}>()
|
||||
|
||||
interface CustomerOptionRow {
|
||||
id: string
|
||||
customerName: string
|
||||
customerNo?: string
|
||||
}
|
||||
|
||||
const customerOptions = ref<CustomerOptionRow[]>([])
|
||||
const customerOptionsLoading = ref(false)
|
||||
|
||||
const isInternal = computed(() => isPlInternalCustomerName(props.modelValue.customerName))
|
||||
const contractDisabled = computed(() => isInternal.value)
|
||||
|
||||
const dibangDirectionLabel = computed(() => {
|
||||
if (props.modelValue.dibangDirection === 'outbound') return '出库'
|
||||
if (props.modelValue.dibangDirection === 'inbound') return '入库'
|
||||
return '无'
|
||||
})
|
||||
|
||||
const contractsModel = computed({
|
||||
get: () => props.modelValue.contracts,
|
||||
set: (value) => patch({ contracts: value })
|
||||
})
|
||||
|
||||
function patch(partial: Partial<PlanLoadForm>) {
|
||||
emit('update:modelValue', { ...props.modelValue, ...partial })
|
||||
}
|
||||
|
||||
function patchAddress(fields: PlAddressApplyPayload) {
|
||||
const partial: Partial<PlanLoadForm> = {
|
||||
address: fields.address,
|
||||
lng: fields.lng,
|
||||
lat: fields.lat
|
||||
}
|
||||
if (fields.contact !== undefined) {
|
||||
partial.contact = fields.contact
|
||||
}
|
||||
patch(partial)
|
||||
}
|
||||
|
||||
function removeStopProduct(index: number) {
|
||||
patch({
|
||||
products: props.modelValue.products.filter((_, i) => i !== index)
|
||||
})
|
||||
}
|
||||
|
||||
function extractCustomerOptions(res: unknown): CustomerOptionRow[] {
|
||||
const unwrapped = (res as { data?: unknown })?.data ?? res
|
||||
if (Array.isArray(unwrapped)) return unwrapped as CustomerOptionRow[]
|
||||
const payload = (unwrapped as { list?: CustomerOptionRow[]; rows?: CustomerOptionRow[] }) || {}
|
||||
return payload.list || payload.rows || []
|
||||
}
|
||||
|
||||
function ensureCustomerOption(customer?: Partial<CustomerOptionRow> | null) {
|
||||
if (!customer?.id) return
|
||||
const id = String(customer.id)
|
||||
const exists = customerOptions.value.some((item) => String(item.id) === id)
|
||||
if (exists) {
|
||||
if (!customer.customerName) return
|
||||
customerOptions.value = customerOptions.value.map((item) =>
|
||||
String(item.id) === id
|
||||
? {
|
||||
...item,
|
||||
customerName: customer.customerName || item.customerName,
|
||||
customerNo: customer.customerNo || item.customerNo
|
||||
}
|
||||
: item
|
||||
)
|
||||
return
|
||||
}
|
||||
customerOptions.value = [
|
||||
{
|
||||
id,
|
||||
customerName: customer.customerName || '',
|
||||
customerNo: customer.customerNo
|
||||
},
|
||||
...customerOptions.value
|
||||
]
|
||||
}
|
||||
|
||||
watch(
|
||||
() => [props.modelValue.customerId, props.modelValue.customerName] as const,
|
||||
([customerId, customerName]) => {
|
||||
if (!customerId) return
|
||||
ensureCustomerOption({
|
||||
id: String(customerId),
|
||||
customerName: customerName || ''
|
||||
})
|
||||
},
|
||||
{ immediate: true }
|
||||
)
|
||||
|
||||
async function loadDefaultCustomerOptions() {
|
||||
customerOptionsLoading.value = true
|
||||
try {
|
||||
const res = await fetchCustomerOptions({ limit: 20 })
|
||||
customerOptions.value = extractCustomerOptions(res)
|
||||
ensureCustomerOption({
|
||||
id: props.modelValue.customerId,
|
||||
customerName: props.modelValue.customerName
|
||||
})
|
||||
} finally {
|
||||
customerOptionsLoading.value = false
|
||||
}
|
||||
}
|
||||
|
||||
async function searchCustomerOptions(query: string) {
|
||||
const keyword = query?.trim()
|
||||
if (!keyword) {
|
||||
await loadDefaultCustomerOptions()
|
||||
return
|
||||
}
|
||||
customerOptionsLoading.value = true
|
||||
try {
|
||||
const res = await fetchCustomerOptions({ keyword, limit: 50 })
|
||||
customerOptions.value = extractCustomerOptions(res)
|
||||
ensureCustomerOption({
|
||||
id: props.modelValue.customerId,
|
||||
customerName: props.modelValue.customerName
|
||||
})
|
||||
} finally {
|
||||
customerOptionsLoading.value = false
|
||||
}
|
||||
}
|
||||
|
||||
function handleCustomerSelectFocus() {
|
||||
if (!customerOptions.value.length) {
|
||||
loadDefaultCustomerOptions()
|
||||
}
|
||||
}
|
||||
|
||||
function handleCustomerChange(customerId?: string) {
|
||||
if (!customerId) {
|
||||
patch({
|
||||
customerId: '',
|
||||
customerName: '',
|
||||
contracts: [],
|
||||
generateDibang: 0,
|
||||
dibangDirection: 'none',
|
||||
address: '',
|
||||
lng: null,
|
||||
lat: null,
|
||||
contact: '',
|
||||
notes: ''
|
||||
})
|
||||
return
|
||||
}
|
||||
if (String(props.modelValue.customerId) === String(customerId)) {
|
||||
ensureCustomerOption({
|
||||
id: customerId,
|
||||
customerName: props.modelValue.customerName
|
||||
})
|
||||
return
|
||||
}
|
||||
const customer = customerOptions.value.find((item) => String(item.id) === String(customerId))
|
||||
const customerName = customer?.customerName || ''
|
||||
const defaults = resolveStopDibangDefaults(customerName, 'load')
|
||||
patch({
|
||||
customerId: String(customerId),
|
||||
customerName,
|
||||
contracts: [],
|
||||
generateDibang: defaults.generateDibang,
|
||||
dibangDirection: defaults.dibangDirection,
|
||||
address: '',
|
||||
lng: null,
|
||||
lat: null,
|
||||
contact: '',
|
||||
notes: ''
|
||||
})
|
||||
void applyStopPrefFromCustomer(String(customerId))
|
||||
}
|
||||
|
||||
async function applyStopPrefFromCustomer(customerId: string) {
|
||||
try {
|
||||
const res = await customerStopPrefApi.get({ customerId, stopType: 'load' })
|
||||
const pref = pickBxData<CustomerStopPref | null>(res)
|
||||
if (!pref) return
|
||||
if (String(props.modelValue.customerId) !== String(customerId)) return
|
||||
const partial: Partial<PlanLoadForm> = {}
|
||||
const prefAddress = (pref.address || '').trim()
|
||||
if (prefAddress) partial.address = prefAddress
|
||||
if (pref.lng != null) partial.lng = pref.lng
|
||||
if (pref.lat != null) partial.lat = pref.lat
|
||||
const prefContact = (pref.contact || '').trim()
|
||||
if (prefContact) partial.contact = prefContact
|
||||
const prefNotes = (pref.notes || '').trim()
|
||||
if (prefNotes) partial.notes = prefNotes
|
||||
if (Object.keys(partial).length) patch(partial)
|
||||
} catch {
|
||||
// 静默:不阻断选客户
|
||||
}
|
||||
}
|
||||
|
||||
function handleDibangToggle(checked: boolean) {
|
||||
const direction = isInternal.value ? 'outbound' : props.modelValue.dibangDirection || 'none'
|
||||
patch({
|
||||
generateDibang: checked ? 1 : 0,
|
||||
dibangDirection: checked ? direction : 'none'
|
||||
})
|
||||
}
|
||||
|
||||
function applyCustomerFromPicker(customer: { id: string | number; customerName?: string }) {
|
||||
ensureCustomerOption({
|
||||
id: String(customer.id),
|
||||
customerName: customer.customerName
|
||||
})
|
||||
handleCustomerChange(String(customer.id))
|
||||
}
|
||||
|
||||
defineExpose({ applyCustomerFromPicker, ensureCustomerOption, searchCustomerOptions })
|
||||
</script>
|
||||
|
||||
<style scoped lang="scss">
|
||||
.pl-plan-load-section__grid {
|
||||
margin-top: 4px;
|
||||
}
|
||||
|
||||
.pl-plan-stop-products-head {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
gap: 12px;
|
||||
margin: 8px 0 0;
|
||||
}
|
||||
|
||||
.pl-plan-stop-products-head__title {
|
||||
font-size: 12px;
|
||||
font-weight: 600;
|
||||
color: #64748b;
|
||||
}
|
||||
|
||||
.pl-plan-load-section__empty-hint {
|
||||
margin: 8px 0 0;
|
||||
font-size: 12px;
|
||||
color: #94a3b8;
|
||||
}
|
||||
|
||||
.pl-plan-dibang-row {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
flex-wrap: wrap;
|
||||
gap: 12px;
|
||||
}
|
||||
|
||||
.pl-plan-dibang-row__hint {
|
||||
font-size: 12px;
|
||||
color: #64748b;
|
||||
}
|
||||
|
||||
.customer-select-row {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 4px;
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.customer-select-row__select {
|
||||
flex: 1 1 auto;
|
||||
min-width: 0;
|
||||
}
|
||||
|
||||
.pl-plan-party-select-row {
|
||||
display: flex;
|
||||
flex-direction: row;
|
||||
align-items: flex-start;
|
||||
gap: 12px;
|
||||
margin-bottom: 8px;
|
||||
}
|
||||
|
||||
.pl-plan-party-select-row__customer {
|
||||
flex: 1.4 1 0;
|
||||
min-width: 0;
|
||||
margin-bottom: 0 !important;
|
||||
}
|
||||
|
||||
.pl-plan-party-select-row__contract {
|
||||
flex: 1 1 0;
|
||||
min-width: 120px;
|
||||
margin-bottom: 0 !important;
|
||||
}
|
||||
|
||||
.pl-plan-contract-trigger {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
flex-wrap: wrap;
|
||||
gap: 8px;
|
||||
min-height: 32px;
|
||||
}
|
||||
|
||||
.pl-plan-contract-trigger__hint {
|
||||
font-size: 12px;
|
||||
color: #64748b;
|
||||
|
||||
&.is-warn {
|
||||
color: #d97706;
|
||||
}
|
||||
}
|
||||
|
||||
.customer-option-row {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
gap: 12px;
|
||||
}
|
||||
|
||||
.customer-option-row__meta {
|
||||
font-size: 12px;
|
||||
color: #94a3b8;
|
||||
}
|
||||
</style>
|
||||
@@ -0,0 +1,154 @@
|
||||
<template>
|
||||
<el-dialog
|
||||
v-model="innerVisible"
|
||||
title="选择磅单二维码"
|
||||
width="560px"
|
||||
align-center
|
||||
class="dialog-form-layout pl-plan-pound-qrcode-pick-dialog"
|
||||
modal-class="order-module-dialog-mask"
|
||||
destroy-on-close
|
||||
@closed="handleClosed"
|
||||
>
|
||||
<p class="pl-plan-pound-qrcode-pick-dialog__hint">
|
||||
本计划关联了多张地磅出入库单,请选择要复制或查看的磅单(不会同时打开多个弹窗)。
|
||||
</p>
|
||||
<el-radio-group v-model="selectedKey" class="pl-plan-pound-qrcode-pick-dialog__list">
|
||||
<el-radio
|
||||
v-for="item in options"
|
||||
:key="item.key"
|
||||
:value="item.key"
|
||||
class="pl-plan-pound-qrcode-pick-dialog__item"
|
||||
>
|
||||
<span class="pl-plan-pound-qrcode-pick-dialog__label">{{ item.label }}</span>
|
||||
<span v-if="item.planNo" class="pl-plan-pound-qrcode-pick-dialog__meta">
|
||||
计划 {{ item.planNo }}
|
||||
</span>
|
||||
</el-radio>
|
||||
</el-radio-group>
|
||||
<template #footer>
|
||||
<el-button @click="innerVisible = false">
|
||||
<el-icon><Close /></el-icon>取消
|
||||
</el-button>
|
||||
<el-button class="btn-ghost" :disabled="!selectedRecord" @click="handlePreview">
|
||||
<el-icon><View /></el-icon>查看二维码
|
||||
</el-button>
|
||||
<el-button type="primary" :disabled="!selectedRecord" @click="handleCopy">
|
||||
<el-icon><CopyDocument /></el-icon>复制二维码
|
||||
</el-button>
|
||||
</template>
|
||||
</el-dialog>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { Close, CopyDocument, View } from '@element-plus/icons-vue'
|
||||
import type { Plan, TransportInventoryLink } from '@/api/pl'
|
||||
import { formatTransportInventoryLinkLabel } from '@/utils/pl-pound-qrcode-display'
|
||||
|
||||
const props = defineProps<{
|
||||
visible: boolean
|
||||
records?: TransportInventoryLink[]
|
||||
plan?: Plan | null
|
||||
}>()
|
||||
|
||||
const emit = defineEmits<{
|
||||
'update:visible': [value: boolean]
|
||||
copy: [record: TransportInventoryLink]
|
||||
preview: [record: TransportInventoryLink]
|
||||
}>()
|
||||
|
||||
const innerVisible = computed({
|
||||
get: () => props.visible,
|
||||
set: (value) => emit('update:visible', value)
|
||||
})
|
||||
|
||||
const selectedKey = ref('')
|
||||
|
||||
const options = computed(() =>
|
||||
(props.records || []).map((record, index) => ({
|
||||
key: `${record.dbInventoryId}-${index}`,
|
||||
label: formatTransportInventoryLinkLabel(record, props.plan),
|
||||
planNo: record.planNo,
|
||||
record
|
||||
}))
|
||||
)
|
||||
|
||||
const selectedRecord = computed(() => {
|
||||
const item = options.value.find((row) => row.key === selectedKey.value)
|
||||
return item?.record
|
||||
})
|
||||
|
||||
watch(
|
||||
() => [props.visible, props.records] as const,
|
||||
([visible, records]) => {
|
||||
if (!visible) return
|
||||
const first = records?.[0]
|
||||
selectedKey.value = first ? `${first.dbInventoryId}-0` : ''
|
||||
},
|
||||
{ immediate: true }
|
||||
)
|
||||
|
||||
function handleClosed() {
|
||||
selectedKey.value = ''
|
||||
}
|
||||
|
||||
function handleCopy() {
|
||||
if (!selectedRecord.value) return
|
||||
emit('copy', selectedRecord.value)
|
||||
innerVisible.value = false
|
||||
}
|
||||
|
||||
function handlePreview() {
|
||||
if (!selectedRecord.value) return
|
||||
emit('preview', selectedRecord.value)
|
||||
innerVisible.value = false
|
||||
}
|
||||
</script>
|
||||
|
||||
<style scoped lang="scss">
|
||||
.pl-plan-pound-qrcode-pick-dialog__hint {
|
||||
margin: 0 0 12px;
|
||||
font-size: 13px;
|
||||
line-height: 1.55;
|
||||
color: var(--mint-text-muted, #64748b);
|
||||
}
|
||||
|
||||
.pl-plan-pound-qrcode-pick-dialog__list {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: stretch;
|
||||
gap: 8px;
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.pl-plan-pound-qrcode-pick-dialog__item {
|
||||
display: flex;
|
||||
align-items: flex-start;
|
||||
margin: 0;
|
||||
padding: 10px 12px;
|
||||
border: 1px solid var(--mint-border, #d9e8e2);
|
||||
border-radius: 8px;
|
||||
width: 100%;
|
||||
height: auto;
|
||||
white-space: normal;
|
||||
|
||||
:deep(.el-radio__label) {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 2px;
|
||||
align-items: flex-start;
|
||||
line-height: 1.45;
|
||||
white-space: normal;
|
||||
}
|
||||
}
|
||||
|
||||
.pl-plan-pound-qrcode-pick-dialog__label {
|
||||
font-size: 14px;
|
||||
font-weight: 600;
|
||||
color: var(--text, #1e293b);
|
||||
}
|
||||
|
||||
.pl-plan-pound-qrcode-pick-dialog__meta {
|
||||
font-size: 12px;
|
||||
color: var(--mint-text-muted, #64748b);
|
||||
}
|
||||
</style>
|
||||
@@ -0,0 +1,638 @@
|
||||
<template>
|
||||
<div v-if="visible" class="pl-plan-stop-feedback-panel">
|
||||
<h4 v-if="panelTitle" class="pl-plan-stop-feedback-panel__title">{{ panelTitle }}</h4>
|
||||
|
||||
<div class="pl-stop-feedback-cards" :class="cardsLayoutClass">
|
||||
<section class="pl-stop-feedback-card">
|
||||
<div class="pl-stop-feedback-ticket">
|
||||
<div class="pl-stop-feedback-ticket__band pl-stop-feedback-ticket__band--driver">
|
||||
<span class="pl-stop-feedback-ticket__who">司机回传</span>
|
||||
<span v-if="driverFeedback?.feedbackTime" class="pl-stop-feedback-ticket__when">{{
|
||||
formatFeedbackTime(driverFeedback.feedbackTime)
|
||||
}}</span>
|
||||
</div>
|
||||
<p v-if="!hasDriverFeedback" class="pl-plan-form-empty-hint pl-stop-feedback-ticket__empty">
|
||||
暂无司机回传
|
||||
</p>
|
||||
<template v-else>
|
||||
<div v-if="driverFeedback?.products?.length" class="pl-stop-feedback-ticket__products">
|
||||
<div
|
||||
v-for="product in driverFeedback.products"
|
||||
:key="product.stopProductId"
|
||||
class="pl-stop-feedback-ticket__product-row"
|
||||
>
|
||||
<span class="pl-stop-feedback-ticket__text">{{ product.productName || '产品' }}</span>
|
||||
<span class="pl-stop-feedback-ticket__text pl-stop-feedback-ticket__text--qty">
|
||||
{{ formatDriverProductQty(product) }}
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
<div v-if="driverRemarkDisplay" class="pl-stop-feedback-ticket__line pl-stop-feedback-ticket__line--full">
|
||||
<span class="pl-stop-feedback-ticket__lab">备注</span>
|
||||
<span class="pl-stop-feedback-ticket__text">{{ driverRemarkDisplay }}</span>
|
||||
</div>
|
||||
<div class="pl-stop-feedback-ticket__foot">
|
||||
<span class="pl-stop-feedback-ticket__lab">附件</span>
|
||||
<AttachmentUploadField
|
||||
v-if="driverAttachmentCsv"
|
||||
class="pl-stop-feedback-ticket__attach"
|
||||
:model-value="driverAttachmentCsv"
|
||||
disabled
|
||||
compact
|
||||
folder="pl/transport/feedback"
|
||||
accept="image/*,video/*,.pdf"
|
||||
:limit="15"
|
||||
/>
|
||||
<span v-else class="pl-plan-form-empty-hint">—</span>
|
||||
</div>
|
||||
</template>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<section v-if="showSiteCard" class="pl-stop-feedback-card">
|
||||
<div class="pl-stop-feedback-ticket">
|
||||
<div class="pl-stop-feedback-ticket__band pl-stop-feedback-ticket__band--site">
|
||||
<span class="pl-stop-feedback-ticket__who">现场回传</span>
|
||||
<span v-if="siteFeedback?.feedbackTime" class="pl-stop-feedback-ticket__when">{{
|
||||
formatFeedbackTime(siteFeedback.feedbackTime)
|
||||
}}</span>
|
||||
</div>
|
||||
<p v-if="!hasSiteFeedback" class="pl-plan-form-empty-hint pl-stop-feedback-ticket__empty">
|
||||
暂无现场回传
|
||||
</p>
|
||||
<template v-else>
|
||||
<div v-if="siteFeedback?.products?.length" class="pl-stop-feedback-ticket__products">
|
||||
<div
|
||||
v-for="product in siteFeedback.products"
|
||||
:key="product.stopProductId"
|
||||
class="pl-stop-feedback-ticket__product-row"
|
||||
>
|
||||
<span class="pl-stop-feedback-ticket__text">{{ product.productName || '产品' }}</span>
|
||||
<span class="pl-stop-feedback-ticket__text pl-stop-feedback-ticket__text--qty">
|
||||
<span class="pl-stop-feedback-ticket__val pl-stop-feedback-ticket__val--highlight">{{
|
||||
formatSiteProductQty(product).qty
|
||||
}}</span>
|
||||
<span class="pl-stop-feedback-ticket__unit">{{ formatSiteProductQty(product).unit }}</span>
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
<div class="pl-stop-feedback-ticket__lines">
|
||||
<div
|
||||
v-if="
|
||||
(siteFeedback?.quantity != null && !siteFeedback?.products?.length) ||
|
||||
siteFeedback?.businessType
|
||||
"
|
||||
class="pl-stop-feedback-ticket__row"
|
||||
>
|
||||
<div
|
||||
v-if="siteFeedback?.quantity != null && !siteFeedback?.products?.length"
|
||||
class="pl-stop-feedback-ticket__line"
|
||||
>
|
||||
<span class="pl-stop-feedback-ticket__lab">数量</span>
|
||||
<span class="pl-stop-feedback-ticket__text pl-stop-feedback-ticket__text--qty">
|
||||
<span class="pl-stop-feedback-ticket__val pl-stop-feedback-ticket__val--highlight">{{
|
||||
siteFeedback.quantity
|
||||
}}</span>
|
||||
<span class="pl-stop-feedback-ticket__unit">吨</span>
|
||||
</span>
|
||||
</div>
|
||||
<div v-if="siteFeedback?.businessType" class="pl-stop-feedback-ticket__line">
|
||||
<span class="pl-stop-feedback-ticket__lab">业务类型</span>
|
||||
<span class="pl-stop-feedback-ticket__text">{{
|
||||
formatSiteBusinessType(siteFeedback.businessType)
|
||||
}}</span>
|
||||
</div>
|
||||
</div>
|
||||
<div v-if="siteFeedback?.remark" class="pl-stop-feedback-ticket__line pl-stop-feedback-ticket__line--full">
|
||||
<span class="pl-stop-feedback-ticket__lab">备注</span>
|
||||
<span class="pl-stop-feedback-ticket__text">{{ siteFeedback.remark }}</span>
|
||||
</div>
|
||||
</div>
|
||||
<div class="pl-stop-feedback-ticket__foot">
|
||||
<span class="pl-stop-feedback-ticket__lab">附件</span>
|
||||
<AttachmentUploadField
|
||||
v-if="siteAttachmentCsv"
|
||||
class="pl-stop-feedback-ticket__attach"
|
||||
:model-value="siteAttachmentCsv"
|
||||
disabled
|
||||
compact
|
||||
folder="pl/transport/site-feedback"
|
||||
accept="image/*,video/*,.pdf"
|
||||
:limit="15"
|
||||
/>
|
||||
<span v-else class="pl-plan-form-empty-hint">—</span>
|
||||
</div>
|
||||
</template>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<section v-if="showDibangCard" class="pl-stop-feedback-card">
|
||||
<div class="pl-stop-feedback-ticket">
|
||||
<div class="pl-stop-feedback-ticket__band pl-stop-feedback-ticket__band--dibang">
|
||||
<span class="pl-stop-feedback-ticket__who">地磅单</span>
|
||||
<span v-if="dibangRows.length === 1" class="pl-stop-feedback-ticket__when">{{
|
||||
dibangBatchNo(dibangRows[0])
|
||||
}}</span>
|
||||
</div>
|
||||
<p
|
||||
v-if="!dibangRows.length"
|
||||
class="pl-plan-form-empty-hint pl-stop-feedback-ticket__empty"
|
||||
>
|
||||
暂无关联地磅单
|
||||
</p>
|
||||
<template v-else>
|
||||
<div
|
||||
v-for="(row, idx) in dibangRows"
|
||||
:key="row.link.dbInventoryId || idx"
|
||||
class="pl-stop-feedback-dibang-item"
|
||||
:class="{ 'pl-stop-feedback-dibang-item--split': dibangRows.length > 1 }"
|
||||
>
|
||||
<p v-if="dibangRows.length > 1" class="pl-stop-feedback-ticket__product">
|
||||
{{ dibangProductLabel(row, idx) }}
|
||||
</p>
|
||||
<div class="pl-stop-feedback-ticket__qty pl-stop-feedback-ticket__qty--compact">
|
||||
<div>
|
||||
<div class="pl-stop-feedback-ticket__lab">{{
|
||||
row.weighing ? '净重(吨)' : '数量(吨)'
|
||||
}}</div>
|
||||
<div class="pl-stop-feedback-ticket__val pl-stop-feedback-ticket__val--highlight">{{
|
||||
dibangPrimaryQty(row)
|
||||
}}</div>
|
||||
</div>
|
||||
<div>
|
||||
<div class="pl-stop-feedback-ticket__lab">{{
|
||||
row.weighing ? '毛/皮(吨)' : '状态'
|
||||
}}</div>
|
||||
<div
|
||||
class="pl-stop-feedback-ticket__val"
|
||||
:class="
|
||||
row.weighing
|
||||
? 'pl-stop-feedback-ticket__val--highlight'
|
||||
: 'pl-stop-feedback-ticket__val--sm'
|
||||
"
|
||||
>
|
||||
{{ dibangSecondaryQty(row) }}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="pl-stop-feedback-ticket__lines pl-stop-feedback-ticket__lines--compact">
|
||||
<div class="pl-stop-feedback-ticket__row">
|
||||
<div class="pl-stop-feedback-ticket__line">
|
||||
<span class="pl-stop-feedback-ticket__lab">单号</span>
|
||||
<span class="pl-stop-feedback-ticket__text">{{ dibangBatchNo(row) }}</span>
|
||||
</div>
|
||||
<div class="pl-stop-feedback-ticket__line">
|
||||
<span class="pl-stop-feedback-ticket__lab">业务</span>
|
||||
<span class="pl-stop-feedback-ticket__text">{{ dibangBusinessType(row) }}</span>
|
||||
</div>
|
||||
</div>
|
||||
<div class="pl-stop-feedback-ticket__line pl-stop-feedback-ticket__line--full">
|
||||
<span class="pl-stop-feedback-ticket__lab">往来</span>
|
||||
<span class="pl-stop-feedback-ticket__text">{{ dibangPartner(row) }}</span>
|
||||
</div>
|
||||
</div>
|
||||
<p v-if="!row.weighing" class="pl-plan-form-empty-hint pl-stop-feedback-ticket__hint">
|
||||
尚未关联地磅明细
|
||||
</p>
|
||||
</div>
|
||||
</template>
|
||||
</div>
|
||||
</section>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { computed } 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'
|
||||
import type { PlPlanTransportDibangRow } from '@/composables/usePlPlanViewDetail'
|
||||
import { formatDateTime } from '@/utils/format'
|
||||
import { isPlInternalCustomerName } from '@/utils/pl-internal-customer'
|
||||
|
||||
const props = withDefaults(
|
||||
defineProps<{
|
||||
stopLabel?: string
|
||||
customerName?: string
|
||||
generateDibang?: number
|
||||
dibangRows?: PlPlanTransportDibangRow[]
|
||||
driverFeedback?: TransportStopFeedback | null
|
||||
siteFeedback?: TransportStopFeedback | null
|
||||
/** 段级无备注时回退展示(如运输单级司机回传备注) */
|
||||
fallbackRemark?: string
|
||||
/** 无回传数据时也展示卡片空态 */
|
||||
showWhenEmpty?: boolean
|
||||
}>(),
|
||||
{
|
||||
stopLabel: '',
|
||||
customerName: '',
|
||||
generateDibang: 0,
|
||||
dibangRows: () => [],
|
||||
driverFeedback: null,
|
||||
siteFeedback: null,
|
||||
fallbackRemark: '',
|
||||
showWhenEmpty: true
|
||||
}
|
||||
)
|
||||
|
||||
const isInternalCustomer = computed(() => isPlInternalCustomerName(props.customerName))
|
||||
|
||||
const showSiteCard = computed(() => isInternalCustomer.value)
|
||||
|
||||
const showDibangCard = computed(
|
||||
() => isInternalCustomer.value && (props.generateDibang === 1 || (props.dibangRows?.length ?? 0) > 0)
|
||||
)
|
||||
|
||||
const cardCount = computed(() => {
|
||||
let count = 1
|
||||
if (showSiteCard.value) count += 1
|
||||
if (showDibangCard.value) count += 1
|
||||
return count
|
||||
})
|
||||
|
||||
const cardsLayoutClass = computed(() => {
|
||||
if (cardCount.value >= 3) return 'is-cols-3'
|
||||
if (cardCount.value === 2) return 'is-cols-2'
|
||||
return 'is-cols-1'
|
||||
})
|
||||
|
||||
const driverRemarkDisplay = computed(() => {
|
||||
const stopRemark = (props.driverFeedback?.remark || '').trim()
|
||||
if (stopRemark) return stopRemark
|
||||
return (props.fallbackRemark || '').trim()
|
||||
})
|
||||
|
||||
const hasDriverFeedback = computed(() =>
|
||||
Boolean(
|
||||
driverRemarkDisplay.value ||
|
||||
props.driverFeedback?.attachmentUrls?.length ||
|
||||
props.driverFeedback?.products?.length ||
|
||||
props.driverFeedback?.feedbackTime
|
||||
)
|
||||
)
|
||||
|
||||
const hasSiteFeedback = computed(() =>
|
||||
Boolean(
|
||||
props.siteFeedback?.quantity != null ||
|
||||
props.siteFeedback?.remark ||
|
||||
props.siteFeedback?.attachmentUrls?.length ||
|
||||
props.siteFeedback?.products?.length ||
|
||||
props.siteFeedback?.feedbackTime
|
||||
)
|
||||
)
|
||||
|
||||
const hasAnyFeedback = computed(
|
||||
() =>
|
||||
hasDriverFeedback.value ||
|
||||
hasSiteFeedback.value ||
|
||||
(props.dibangRows?.length ?? 0) > 0
|
||||
)
|
||||
|
||||
const visible = computed(() => props.showWhenEmpty || hasAnyFeedback.value)
|
||||
|
||||
const panelTitle = computed(() =>
|
||||
props.stopLabel ? `${props.stopLabel} · 执行回传` : '执行回传'
|
||||
)
|
||||
|
||||
const driverAttachmentCsv = computed(() => (props.driverFeedback?.attachmentUrls || []).join(','))
|
||||
const siteAttachmentCsv = computed(() => (props.siteFeedback?.attachmentUrls || []).join(','))
|
||||
|
||||
function formatFeedbackTime(value?: string) {
|
||||
return formatDateTime(value) || '—'
|
||||
}
|
||||
|
||||
function formatSiteBusinessType(value?: string) {
|
||||
const text = (value || '').trim()
|
||||
if (text === 'outbound') return '出库'
|
||||
if (text === 'inbound') return '入库'
|
||||
return text || '—'
|
||||
}
|
||||
|
||||
function formatDriverProductQty(product: NonNullable<TransportStopFeedback['products']>[number]) {
|
||||
const qty = product.actualQty
|
||||
const unit = product.unit || '吨'
|
||||
if (qty == null) return '—'
|
||||
return `${qty} ${unit}`
|
||||
}
|
||||
|
||||
function formatSiteProductQty(product: NonNullable<TransportStopFeedback['products']>[number]) {
|
||||
const qty = product.actualQty ?? product.quantity
|
||||
const unit = product.unit || '吨'
|
||||
if (qty == null) return { qty: '—', unit: '' }
|
||||
return { qty: String(qty), unit: ` ${unit}` }
|
||||
}
|
||||
|
||||
function dibangProductLabel(row: PlPlanTransportDibangRow, idx: number): string {
|
||||
return row.link.productName || row.inventory?.product || `地磅 ${idx + 1}`
|
||||
}
|
||||
|
||||
function dibangBatchNo(row: PlPlanTransportDibangRow): string {
|
||||
return row.weighing?.batchNo || row.inventory?.batchNo || row.link.batchNo || '—'
|
||||
}
|
||||
|
||||
function dibangBusinessType(row: PlPlanTransportDibangRow): string {
|
||||
return row.weighing?.businessType || row.inventory?.businessType || '—'
|
||||
}
|
||||
|
||||
function dibangPartner(row: PlPlanTransportDibangRow): string {
|
||||
if (row.inventory?.partnerCompany) return row.inventory.partnerCompany
|
||||
const weighing = row.weighing
|
||||
if (!weighing) return '—'
|
||||
const businessType = dibangBusinessType(row)
|
||||
if (businessType === '入库') return weighing.supplier || weighing.consignee || '—'
|
||||
return weighing.consignee || weighing.supplier || '—'
|
||||
}
|
||||
|
||||
function dibangPrimaryQty(row: PlPlanTransportDibangRow): string {
|
||||
if (row.weighing) return formatKgToTon(row.weighing.netWeight)
|
||||
if (row.inventory?.quantity != null && row.inventory.quantity !== undefined) {
|
||||
return String(row.inventory.quantity)
|
||||
}
|
||||
return '—'
|
||||
}
|
||||
|
||||
function dibangSecondaryQty(row: PlPlanTransportDibangRow): string {
|
||||
if (row.weighing) {
|
||||
return `${formatKgToTon(row.weighing.grossWeight)} / ${formatKgToTon(row.weighing.tareWeight)}`
|
||||
}
|
||||
return row.inventory?.status || '—'
|
||||
}
|
||||
</script>
|
||||
|
||||
<style scoped lang="scss">
|
||||
.pl-plan-stop-feedback-panel {
|
||||
margin-top: 12px;
|
||||
padding-top: 12px;
|
||||
border-top: 1px dashed #e2e8f0;
|
||||
}
|
||||
|
||||
.pl-plan-stop-feedback-panel__title {
|
||||
margin: 0 0 10px;
|
||||
font-size: 13px;
|
||||
font-weight: 600;
|
||||
color: #475569;
|
||||
}
|
||||
|
||||
.pl-stop-feedback-cards {
|
||||
display: grid;
|
||||
gap: 10px;
|
||||
align-items: stretch;
|
||||
|
||||
&.is-cols-1 {
|
||||
grid-template-columns: minmax(0, 280px);
|
||||
}
|
||||
|
||||
&.is-cols-2 {
|
||||
grid-template-columns: repeat(2, minmax(0, 1fr));
|
||||
}
|
||||
|
||||
&.is-cols-3 {
|
||||
grid-template-columns: repeat(3, minmax(0, 1fr));
|
||||
}
|
||||
}
|
||||
|
||||
.pl-stop-feedback-card {
|
||||
min-width: 0;
|
||||
min-height: 100%;
|
||||
border: 1px solid #e2e8f0;
|
||||
border-radius: 8px;
|
||||
overflow: hidden;
|
||||
background: #fff;
|
||||
}
|
||||
|
||||
.pl-stop-feedback-ticket {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
min-height: 100%;
|
||||
background: #fff;
|
||||
}
|
||||
|
||||
.pl-stop-feedback-ticket__band {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
gap: 8px;
|
||||
padding: 8px 10px;
|
||||
border-bottom: 1px solid #e2e8f0;
|
||||
|
||||
&--driver {
|
||||
background: linear-gradient(90deg, #ecfdf5 0%, #f8fafc 100%);
|
||||
}
|
||||
|
||||
&--site {
|
||||
background: linear-gradient(90deg, #eff6ff 0%, #f8fafc 100%);
|
||||
}
|
||||
|
||||
&--dibang {
|
||||
background: linear-gradient(90deg, #fff7ed 0%, #f8fafc 100%);
|
||||
}
|
||||
}
|
||||
|
||||
.pl-stop-feedback-ticket__who {
|
||||
font-size: 12px;
|
||||
font-weight: 600;
|
||||
color: #1e293b;
|
||||
}
|
||||
|
||||
.pl-stop-feedback-ticket__when {
|
||||
flex-shrink: 0;
|
||||
max-width: 52%;
|
||||
font-size: 11px;
|
||||
color: #64748b;
|
||||
text-align: right;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
.pl-stop-feedback-ticket__product {
|
||||
margin: 0;
|
||||
padding: 8px 10px 0;
|
||||
font-size: 12px;
|
||||
font-weight: 500;
|
||||
color: #334155;
|
||||
}
|
||||
|
||||
.pl-stop-feedback-ticket__qty {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(2, minmax(0, 1fr));
|
||||
gap: 8px;
|
||||
padding: 8px 10px;
|
||||
|
||||
&--compact {
|
||||
padding-top: 4px;
|
||||
}
|
||||
}
|
||||
|
||||
.pl-stop-feedback-ticket__lab {
|
||||
font-size: 11px;
|
||||
color: #64748b;
|
||||
}
|
||||
|
||||
.pl-stop-feedback-ticket__val {
|
||||
margin-top: 2px;
|
||||
font-size: 16px;
|
||||
font-weight: 600;
|
||||
color: #0f172a;
|
||||
line-height: 1.2;
|
||||
|
||||
&--highlight {
|
||||
font-size: 18px;
|
||||
font-weight: 700;
|
||||
color: #059669;
|
||||
font-variant-numeric: tabular-nums;
|
||||
}
|
||||
|
||||
&--sm {
|
||||
font-size: 12px;
|
||||
font-weight: 500;
|
||||
}
|
||||
}
|
||||
|
||||
.pl-stop-feedback-ticket__lines {
|
||||
padding: 0 10px 8px;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 4px;
|
||||
|
||||
&--compact {
|
||||
padding-top: 0;
|
||||
}
|
||||
}
|
||||
|
||||
.pl-stop-feedback-ticket__row {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(2, minmax(0, 1fr));
|
||||
gap: 8px;
|
||||
padding: 0;
|
||||
}
|
||||
|
||||
.pl-stop-feedback-ticket__line {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 2px;
|
||||
min-width: 0;
|
||||
padding: 0 10px 6px;
|
||||
}
|
||||
|
||||
.pl-stop-feedback-ticket__lines .pl-stop-feedback-ticket__line {
|
||||
padding: 0;
|
||||
}
|
||||
|
||||
.pl-stop-feedback-ticket__lines .pl-stop-feedback-ticket__line--full {
|
||||
padding: 0;
|
||||
}
|
||||
|
||||
.pl-stop-feedback-ticket__text {
|
||||
font-size: 12px;
|
||||
color: #1e293b;
|
||||
word-break: break-word;
|
||||
line-height: 1.4;
|
||||
}
|
||||
|
||||
.pl-stop-feedback-ticket__products {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 4px;
|
||||
padding: 8px 10px 0;
|
||||
}
|
||||
|
||||
.pl-stop-feedback-ticket__product-row {
|
||||
display: flex;
|
||||
align-items: baseline;
|
||||
justify-content: space-between;
|
||||
gap: 6px;
|
||||
}
|
||||
|
||||
.pl-stop-feedback-ticket__text--qty {
|
||||
display: inline-flex;
|
||||
align-items: baseline;
|
||||
gap: 2px;
|
||||
flex-shrink: 0;
|
||||
font-size: 12px;
|
||||
font-weight: 400;
|
||||
color: #64748b;
|
||||
|
||||
.pl-stop-feedback-ticket__val--highlight {
|
||||
font-size: 18px;
|
||||
font-weight: 700;
|
||||
color: #059669;
|
||||
font-variant-numeric: tabular-nums;
|
||||
line-height: 1.2;
|
||||
}
|
||||
}
|
||||
|
||||
.pl-stop-feedback-ticket__unit {
|
||||
font-size: 12px;
|
||||
font-weight: 400;
|
||||
color: #64748b;
|
||||
}
|
||||
|
||||
.pl-stop-feedback-ticket__foot {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 4px;
|
||||
margin-top: auto;
|
||||
padding: 8px 10px 10px;
|
||||
border-top: 1px solid #f1f5f9;
|
||||
}
|
||||
|
||||
.pl-stop-feedback-ticket__empty {
|
||||
padding: 12px 10px;
|
||||
flex: 1;
|
||||
}
|
||||
|
||||
.pl-stop-feedback-ticket__hint {
|
||||
margin: 0;
|
||||
padding: 0 10px 8px;
|
||||
font-size: 12px;
|
||||
}
|
||||
|
||||
.pl-stop-feedback-dibang-item {
|
||||
&--split + &--split {
|
||||
border-top: 1px dashed #e2e8f0;
|
||||
margin-top: 4px;
|
||||
padding-top: 4px;
|
||||
}
|
||||
}
|
||||
|
||||
.pl-plan-form-empty-hint {
|
||||
margin: 0;
|
||||
font-size: 12px;
|
||||
color: var(--mint-text-muted, #94a3b8);
|
||||
}
|
||||
|
||||
.pl-stop-feedback-ticket__attach {
|
||||
:deep(.attachment-list) {
|
||||
gap: 4px;
|
||||
}
|
||||
|
||||
:deep(.attachment-item) {
|
||||
width: 56px;
|
||||
border-radius: 6px;
|
||||
}
|
||||
|
||||
:deep(.attachment-preview) {
|
||||
height: 40px;
|
||||
}
|
||||
}
|
||||
|
||||
@media (max-width: 1280px) {
|
||||
.pl-stop-feedback-cards.is-cols-3 {
|
||||
grid-template-columns: repeat(2, minmax(0, 1fr));
|
||||
}
|
||||
}
|
||||
|
||||
@media (max-width: 900px) {
|
||||
.pl-stop-feedback-cards.is-cols-2,
|
||||
.pl-stop-feedback-cards.is-cols-3 {
|
||||
grid-template-columns: 1fr;
|
||||
}
|
||||
|
||||
.pl-stop-feedback-cards.is-cols-1 {
|
||||
grid-template-columns: 1fr;
|
||||
max-width: none;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
@@ -0,0 +1,686 @@
|
||||
<template>
|
||||
<div
|
||||
class="panel dialog-list-panel pl-plan-stop-product-table-wrap"
|
||||
:class="{ 'is-compact': compact, 'is-editable': editable }"
|
||||
>
|
||||
<div class="list-body list-wrap dialog-list-body-only">
|
||||
<!-- compact:双行列表(方案 A) -->
|
||||
<div v-if="compact" class="pl-stop-product-dual-list">
|
||||
<p v-if="!products.length" class="pl-stop-product-dual-empty"> 暂无产品 </p>
|
||||
<article
|
||||
v-for="(row, index) in products"
|
||||
v-else
|
||||
:key="`${row.productId}-${row.planProductId || index}`"
|
||||
class="pl-stop-product-dual-item"
|
||||
>
|
||||
<div class="pl-stop-product-dual-item__row1">
|
||||
<div class="pl-stop-product-dual-item__field pl-stop-product-dual-item__product">
|
||||
<span class="pl-stop-product-dual-item__label">产品名称</span>
|
||||
<PlProductNameHazardCell
|
||||
:product="{ ...row, productName: row.standardProductName || row.productName }"
|
||||
/>
|
||||
</div>
|
||||
<div class="pl-stop-product-dual-item__field">
|
||||
<span class="pl-stop-product-dual-item__label">别名</span>
|
||||
<div v-if="sharedEditable" class="line-meta-cell">
|
||||
<el-select
|
||||
v-if="(row.aliasOptions || []).length"
|
||||
v-model="row.aliasName"
|
||||
class="pl-plan-product-cell-control line-meta-cell__control"
|
||||
placeholder="不选则用产品名称"
|
||||
clearable
|
||||
filterable
|
||||
popper-class="pl-plan-alias-brand-select-dropdown"
|
||||
@change="() => handleAliasChange(row)"
|
||||
>
|
||||
<el-option
|
||||
v-for="name in row.aliasOptions"
|
||||
:key="name"
|
||||
:label="name"
|
||||
:value="name"
|
||||
/>
|
||||
</el-select>
|
||||
<span v-else class="text-muted line-meta-cell__empty">—</span>
|
||||
<el-button
|
||||
v-if="row.productId"
|
||||
link
|
||||
type="primary"
|
||||
class="line-meta-cell__btn"
|
||||
@click="openAliasBrandManage(row, 'alias')"
|
||||
>
|
||||
<el-icon><Plus /></el-icon>
|
||||
</el-button>
|
||||
</div>
|
||||
<span v-else class="pl-stop-product-dual-item__readonly">{{
|
||||
row.aliasName || '—'
|
||||
}}</span>
|
||||
</div>
|
||||
<div class="pl-stop-product-dual-item__field">
|
||||
<span class="pl-stop-product-dual-item__label">品牌</span>
|
||||
<div v-if="sharedEditable" class="line-meta-cell">
|
||||
<el-select
|
||||
v-if="(row.brandOptions || []).length"
|
||||
v-model="row.brandId"
|
||||
class="pl-plan-product-cell-control line-meta-cell__control"
|
||||
placeholder="不限品牌"
|
||||
clearable
|
||||
filterable
|
||||
popper-class="pl-plan-alias-brand-select-dropdown"
|
||||
@change="(val) => handleBrandChange(row, val)"
|
||||
>
|
||||
<el-option
|
||||
v-for="b in row.brandOptions"
|
||||
:key="b.id"
|
||||
:label="b.brandName"
|
||||
:value="b.id"
|
||||
/>
|
||||
</el-select>
|
||||
<span v-else class="text-muted line-meta-cell__empty">—</span>
|
||||
<el-button
|
||||
v-if="row.productId"
|
||||
link
|
||||
type="primary"
|
||||
class="line-meta-cell__btn"
|
||||
@click="openAliasBrandManage(row, 'brand')"
|
||||
>
|
||||
<el-icon><Plus /></el-icon>
|
||||
</el-button>
|
||||
</div>
|
||||
<span v-else class="pl-stop-product-dual-item__readonly">
|
||||
{{ formatBrandConstraintLabel(row.brandMode, row.brandName) }}
|
||||
</span>
|
||||
</div>
|
||||
<div class="pl-stop-product-dual-item__field">
|
||||
<span class="pl-stop-product-dual-item__label">规格型号</span>
|
||||
<span class="pl-stop-product-dual-item__readonly">{{ row.model || '—' }}</span>
|
||||
</div>
|
||||
<div class="pl-stop-product-dual-item__field">
|
||||
<span class="pl-stop-product-dual-item__label">单位</span>
|
||||
<DictSelect
|
||||
v-if="sharedEditable"
|
||||
v-model="row.unit"
|
||||
class="pl-plan-product-cell-control pl-stop-product-dual-dict"
|
||||
dict-type="crm_product_unit"
|
||||
placeholder="单位"
|
||||
/>
|
||||
<template v-else>
|
||||
<span class="pl-stop-product-dual-item__readonly">{{
|
||||
resolveDictLabel('crm_product_unit', row.unit)
|
||||
}}</span>
|
||||
</template>
|
||||
</div>
|
||||
</div>
|
||||
<div class="pl-stop-product-dual-item__row2">
|
||||
<div class="pl-stop-product-dual-item__field">
|
||||
<span class="pl-stop-product-dual-item__label">计划数量</span>
|
||||
<el-input-number
|
||||
v-if="editable"
|
||||
v-model="row.planQty"
|
||||
:min="0"
|
||||
:precision="3"
|
||||
:controls="false"
|
||||
class="pl-plan-product-cell-control pl-stop-product-dual-qty"
|
||||
/>
|
||||
<span
|
||||
v-else
|
||||
class="pl-stop-product-dual-item__readonly pl-stop-product-dual-item__qty-text"
|
||||
>
|
||||
{{ row.planQty ?? '—' }}
|
||||
</span>
|
||||
</div>
|
||||
<div class="pl-stop-product-dual-item__field">
|
||||
<span class="pl-stop-product-dual-item__label">包装规格</span>
|
||||
<DictSelect
|
||||
v-if="sharedEditable"
|
||||
v-model="row.packageSpec"
|
||||
class="pl-plan-product-cell-control pl-stop-product-dual-dict"
|
||||
dict-type="crm_product_gg"
|
||||
placeholder="包装"
|
||||
/>
|
||||
<span v-else class="pl-stop-product-dual-item__readonly">{{
|
||||
resolveDictLabel('crm_product_gg', row.packageSpec)
|
||||
}}</span>
|
||||
</div>
|
||||
<div class="pl-stop-product-dual-item__field">
|
||||
<span class="pl-stop-product-dual-item__label">送货方式</span>
|
||||
<DictSelect
|
||||
v-if="sharedEditable"
|
||||
v-model="row.deliveryMethod"
|
||||
class="pl-plan-product-cell-control pl-stop-product-dual-dict"
|
||||
dict-type="crm_shfs"
|
||||
placeholder="送货"
|
||||
/>
|
||||
<span v-else class="pl-stop-product-dual-item__readonly">{{
|
||||
row.deliveryMethod ? getDeliveryMethodDisplay(row.deliveryMethod) : '—'
|
||||
}}</span>
|
||||
</div>
|
||||
<div class="pl-stop-product-dual-item__field pl-stop-product-dual-item__field--remark">
|
||||
<span class="pl-stop-product-dual-item__label">备注</span>
|
||||
<el-input
|
||||
v-if="editable"
|
||||
v-model="row.remark"
|
||||
class="pl-plan-product-cell-control"
|
||||
placeholder="备注"
|
||||
/>
|
||||
<span v-else class="pl-stop-product-dual-item__readonly">{{
|
||||
row.remark || '—'
|
||||
}}</span>
|
||||
</div>
|
||||
<div v-if="canRemove" class="pl-stop-product-dual-item__act">
|
||||
<el-button link type="danger" @click="handleRemove(index)">
|
||||
<el-icon><Delete /></el-icon>
|
||||
</el-button>
|
||||
</div>
|
||||
</div>
|
||||
<div
|
||||
v-if="showStopActualQty || showStopArchivePrice"
|
||||
class="pl-stop-product-dual-item__row3"
|
||||
>
|
||||
<div v-if="showStopActualQty" class="pl-stop-product-dual-item__field">
|
||||
<span class="pl-stop-product-dual-item__label">实际数量</span>
|
||||
<span
|
||||
class="pl-stop-product-dual-item__readonly pl-stop-product-dual-item__qty-text"
|
||||
>
|
||||
{{ formatStopQty(resolveStopActualQty(row, stopArchiveMode)) }}
|
||||
</span>
|
||||
</div>
|
||||
<div v-if="showStopArchivePrice" class="pl-stop-product-dual-item__field">
|
||||
<span class="pl-stop-product-dual-item__label">单价(元)</span>
|
||||
<span class="pl-stop-product-dual-item__readonly">
|
||||
{{ formatStopPrice(resolveStopUnitPrice(row, stopArchiveMode)) }}
|
||||
</span>
|
||||
</div>
|
||||
<div v-if="showStopArchivePrice" class="pl-stop-product-dual-item__field">
|
||||
<span class="pl-stop-product-dual-item__label">金额(元)</span>
|
||||
<span class="pl-stop-product-dual-item__readonly">
|
||||
{{ formatStopArchiveAmount(row, stopArchiveMode) }}
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
</article>
|
||||
</div>
|
||||
|
||||
<!-- 非 compact:完整表格 -->
|
||||
<el-table
|
||||
v-else
|
||||
:data="products"
|
||||
stripe
|
||||
class="list-table pl-plan-stop-product-table"
|
||||
empty-text="暂无产品"
|
||||
>
|
||||
<el-table-column label="产品名称" min-width="140" show-overflow-tooltip>
|
||||
<template #default="{ row }">
|
||||
<PlProductNameHazardCell
|
||||
:product="{ ...row, productName: row.standardProductName || row.productName }"
|
||||
/>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="别名" min-width="140" align="center" show-overflow-tooltip>
|
||||
<template #default="{ row }">
|
||||
{{ row.aliasName || '—' }}
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="品牌" min-width="140" align="center" show-overflow-tooltip>
|
||||
<template #default="{ row }">
|
||||
{{ formatBrandConstraintLabel(row.brandMode, row.brandName) }}
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="型号/规格" min-width="120" show-overflow-tooltip>
|
||||
<template #default="{ row }">
|
||||
{{ row.model || '—' }}
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="单位" min-width="100" align="center">
|
||||
<template #default="{ row }">
|
||||
<DictSelect
|
||||
v-if="sharedEditable"
|
||||
v-model="row.unit"
|
||||
class="pl-plan-product-cell-control"
|
||||
dict-type="crm_product_unit"
|
||||
placeholder="请选择单位"
|
||||
style="width: 100%"
|
||||
/>
|
||||
<template v-else>
|
||||
<DictTag v-if="row.unit" dict-type="crm_product_unit" :value="row.unit" />
|
||||
<span v-else>—</span>
|
||||
</template>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="计划数量" min-width="110" align="right">
|
||||
<template #default="{ row }">
|
||||
<el-input-number
|
||||
v-if="editable"
|
||||
v-model="row.planQty"
|
||||
:min="0"
|
||||
:precision="3"
|
||||
:controls="false"
|
||||
style="width: 100%"
|
||||
/>
|
||||
<span v-else>{{ row.planQty ?? '—' }}</span>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column
|
||||
v-if="showStopActualQty"
|
||||
label="实际数量"
|
||||
min-width="110"
|
||||
align="right"
|
||||
>
|
||||
<template #default="{ row }">
|
||||
{{ formatStopQty(resolveStopActualQty(row, stopArchiveMode)) }}
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column
|
||||
v-if="showStopArchivePrice"
|
||||
label="单价(元)"
|
||||
min-width="120"
|
||||
align="right"
|
||||
>
|
||||
<template #default="{ row }">
|
||||
{{ formatStopPrice(resolveStopUnitPrice(row, stopArchiveMode)) }}
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column
|
||||
v-if="showStopArchivePrice"
|
||||
label="金额(元)"
|
||||
min-width="110"
|
||||
align="right"
|
||||
>
|
||||
<template #default="{ row }">
|
||||
{{ formatStopArchiveAmount(row, stopArchiveMode) }}
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column prop="packageSpec" label="包装规格" min-width="100" align="center">
|
||||
<template #default="{ row }">
|
||||
<DictSelect
|
||||
v-if="sharedEditable"
|
||||
v-model="row.packageSpec"
|
||||
class="pl-plan-product-cell-control"
|
||||
dict-type="crm_product_gg"
|
||||
placeholder="请选择包装规格"
|
||||
style="width: 100%"
|
||||
/>
|
||||
<template v-else>
|
||||
<DictTag v-if="row.packageSpec" dict-type="crm_product_gg" :value="row.packageSpec" />
|
||||
<span v-else>—</span>
|
||||
</template>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="送货方式" min-width="100" align="center">
|
||||
<template #default="{ row }">
|
||||
<DictSelect
|
||||
v-if="sharedEditable"
|
||||
v-model="row.deliveryMethod"
|
||||
class="pl-plan-product-cell-control"
|
||||
dict-type="crm_shfs"
|
||||
placeholder="请选择送货方式"
|
||||
style="width: 100%"
|
||||
/>
|
||||
<template v-else>
|
||||
<el-tag v-if="row.deliveryMethod" size="small" type="info">
|
||||
{{ getDeliveryMethodDisplay(row.deliveryMethod) }}
|
||||
</el-tag>
|
||||
<span v-else>—</span>
|
||||
</template>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column v-if="editable" label="备注" min-width="140">
|
||||
<template #default="{ row }">
|
||||
<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 />
|
||||
<el-table-column
|
||||
v-if="canRemove"
|
||||
label="操作"
|
||||
min-width="56"
|
||||
align="center"
|
||||
fixed="right"
|
||||
class-name="col-actions"
|
||||
>
|
||||
<template #default="{ $index }">
|
||||
<el-button link type="danger" @click="handleRemove($index)">
|
||||
<el-icon><Delete /></el-icon>
|
||||
</el-button>
|
||||
</template>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
</div>
|
||||
|
||||
<ProductAliasBrandDialog
|
||||
v-if="editable"
|
||||
v-model="aliasBrandManageVisible"
|
||||
:product-id="aliasBrandManageProductId"
|
||||
:product-name="aliasBrandManageProductName"
|
||||
:mode="aliasBrandManageMode"
|
||||
@saved="handleAliasBrandManaged"
|
||||
/>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { Delete, Plus } from '@element-plus/icons-vue'
|
||||
import type { PlanStopProductFormRow } from '@/utils/pl-plan-stop-form'
|
||||
import {
|
||||
formatStopArchiveAmount,
|
||||
resolveStopActualQty,
|
||||
resolveStopUnitPrice
|
||||
} from '@/utils/pl-plan-stop-form'
|
||||
import { getDeliveryMethodLabel } from '@/composables/usePlContractToPlan'
|
||||
import {
|
||||
applyBrandSelectChange,
|
||||
applyManagedProductMetaToLines,
|
||||
formatBrandConstraintLabel,
|
||||
resolveLineProductName
|
||||
} from '@/utils/crm-product-brand'
|
||||
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 = withDefaults(
|
||||
defineProps<{
|
||||
products: PlanStopProductFormRow[]
|
||||
editable?: boolean
|
||||
/** 段内双行列表(装货/送货 pane) */
|
||||
compact?: boolean
|
||||
/** 是否允许删除行,默认跟 editable */
|
||||
allowRemove?: boolean
|
||||
/** 共享字段只读(送货段:别名/品牌/单位/包装/送货方式跟装货) */
|
||||
sharedReadonly?: boolean
|
||||
/** 查看态:展示段级实际数量(装货 inbound / 送货 outbound) */
|
||||
showStopActualQty?: boolean
|
||||
/** 查看态:展示段级单价与金额(仅运输计划归档) */
|
||||
showStopArchivePrice?: boolean
|
||||
/** 与 showStopActualQty / showStopArchivePrice 配合 */
|
||||
stopArchiveMode?: 'load' | 'delivery'
|
||||
}>(),
|
||||
{
|
||||
compact: false,
|
||||
allowRemove: undefined,
|
||||
sharedReadonly: false,
|
||||
showStopActualQty: false,
|
||||
showStopArchivePrice: false,
|
||||
stopArchiveMode: 'load'
|
||||
}
|
||||
)
|
||||
|
||||
const emit = defineEmits<{
|
||||
remove: [index: number]
|
||||
}>()
|
||||
|
||||
const sharedEditable = computed(() => !!props.editable && !props.sharedReadonly)
|
||||
const canRemove = computed(
|
||||
() => !!props.editable && (props.allowRemove === undefined ? true : props.allowRemove)
|
||||
)
|
||||
|
||||
const dictStore = useDictStore()
|
||||
|
||||
const aliasBrandManageVisible = ref(false)
|
||||
const aliasBrandManageProductId = ref('')
|
||||
const aliasBrandManageProductName = ref('')
|
||||
const aliasBrandManageMode = ref<'alias' | 'brand'>('alias')
|
||||
|
||||
function handleRemove(index: number) {
|
||||
emit('remove', index)
|
||||
}
|
||||
|
||||
function getDeliveryMethodDisplay(method?: string) {
|
||||
const label = dictStore.getLabel('crm_shfs', method || '')
|
||||
if (label && label !== method) return label
|
||||
return getDeliveryMethodLabel(method)
|
||||
}
|
||||
|
||||
function resolveDictLabel(dictType: string, value?: string | null) {
|
||||
const raw = String(value || '').trim()
|
||||
if (!raw) return '—'
|
||||
const label = dictStore.getLabel(dictType, raw)
|
||||
return label && label !== raw ? label : raw
|
||||
}
|
||||
|
||||
function formatStopQty(value?: number | null) {
|
||||
return value != null && Number.isFinite(Number(value)) ? String(value) : '—'
|
||||
}
|
||||
|
||||
function formatStopPrice(value?: number | null) {
|
||||
return value != null && Number.isFinite(Number(value)) ? Number(value).toFixed(2) : '—'
|
||||
}
|
||||
|
||||
function handleAliasChange(row: PlanStopProductFormRow) {
|
||||
row.productName = resolveLineProductName(row.standardProductName, row.aliasName)
|
||||
}
|
||||
|
||||
function handleBrandChange(row: PlanStopProductFormRow, val: string | undefined | null) {
|
||||
applyBrandSelectChange(row, val, row.brandOptions || [])
|
||||
}
|
||||
|
||||
function openAliasBrandManage(row: PlanStopProductFormRow, 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, unknown>) {
|
||||
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-stop-product-table-wrap {
|
||||
margin-top: 8px;
|
||||
|
||||
&.is-compact {
|
||||
margin-top: 6px;
|
||||
|
||||
:deep(.list-body.list-wrap.dialog-list-body-only) {
|
||||
border-top: none;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.pl-plan-stop-product-meta {
|
||||
display: block;
|
||||
margin-top: 2px;
|
||||
font-size: 11px;
|
||||
line-height: 1.35;
|
||||
color: #64748b;
|
||||
}
|
||||
|
||||
.pl-plan-product-cell-control {
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.pl-stop-product-dual-list {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 8px;
|
||||
}
|
||||
|
||||
.pl-stop-product-dual-empty {
|
||||
margin: 0;
|
||||
padding: 16px 12px;
|
||||
text-align: center;
|
||||
font-size: 12px;
|
||||
color: #64748b;
|
||||
border: 1px solid #d9e8e2;
|
||||
border-radius: 8px;
|
||||
}
|
||||
|
||||
.pl-stop-product-dual-item {
|
||||
border: 1px solid #d9e8e2;
|
||||
border-radius: 8px;
|
||||
overflow: hidden;
|
||||
background: #fff;
|
||||
}
|
||||
|
||||
.pl-stop-product-dual-item__row1,
|
||||
.pl-stop-product-dual-item__row2,
|
||||
.pl-stop-product-dual-item__row3 {
|
||||
display: grid;
|
||||
/* 上下共用同一套 5 列轨道,保证第一列左右对齐;下行仅 4 个字段占前 4 列 */
|
||||
grid-template-columns: repeat(5, minmax(0, 1fr));
|
||||
gap: 8px 12px;
|
||||
padding: 10px 12px;
|
||||
align-items: start;
|
||||
background: #fff;
|
||||
}
|
||||
|
||||
.pl-stop-product-dual-item__row1 {
|
||||
border-bottom: 1px solid #eef2f0;
|
||||
}
|
||||
|
||||
.pl-stop-product-dual-item__row3 {
|
||||
border-top: 1px solid #eef2f0;
|
||||
}
|
||||
|
||||
/* 可编辑:末列留给删除按钮(上下同行宽,删除键只在第二行) */
|
||||
.pl-plan-stop-product-table-wrap.is-compact.is-editable {
|
||||
.pl-stop-product-dual-item__row1,
|
||||
.pl-stop-product-dual-item__row2 {
|
||||
grid-template-columns: repeat(5, minmax(0, 1fr)) 36px;
|
||||
}
|
||||
|
||||
.pl-stop-product-dual-item__act {
|
||||
grid-column: 6;
|
||||
}
|
||||
}
|
||||
|
||||
.pl-stop-product-dual-item__field {
|
||||
min-width: 0;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: flex-start;
|
||||
gap: 4px;
|
||||
|
||||
&--remark {
|
||||
min-width: 0;
|
||||
}
|
||||
}
|
||||
|
||||
.pl-stop-product-dual-item__label {
|
||||
font-size: 10px;
|
||||
font-weight: 600;
|
||||
color: #64748b;
|
||||
line-height: 1.2;
|
||||
}
|
||||
|
||||
.pl-stop-product-dual-item__readonly {
|
||||
font-size: 12px;
|
||||
color: #1e293b;
|
||||
word-break: break-all;
|
||||
line-height: 1.4;
|
||||
min-height: 22px;
|
||||
width: 100%;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: flex-start;
|
||||
}
|
||||
|
||||
.pl-stop-product-dual-item__qty-text {
|
||||
justify-content: flex-start;
|
||||
font-weight: 600;
|
||||
color: #059669;
|
||||
}
|
||||
|
||||
.pl-stop-product-dual-item__act {
|
||||
display: flex;
|
||||
align-items: flex-end;
|
||||
justify-content: center;
|
||||
min-height: 32px;
|
||||
}
|
||||
|
||||
.pl-stop-product-dual-qty {
|
||||
width: 100%;
|
||||
|
||||
:deep(.el-input__wrapper) {
|
||||
padding-left: 8px;
|
||||
padding-right: 8px;
|
||||
}
|
||||
|
||||
:deep(.el-input__inner) {
|
||||
text-align: left;
|
||||
font-weight: 600;
|
||||
}
|
||||
}
|
||||
|
||||
.pl-stop-product-dual-dict {
|
||||
:deep(.el-select__wrapper) {
|
||||
min-height: 32px;
|
||||
padding: 0 8px;
|
||||
font-size: 12px;
|
||||
}
|
||||
}
|
||||
|
||||
.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;
|
||||
font-size: 12px;
|
||||
}
|
||||
|
||||
.line-meta-cell__btn {
|
||||
flex-shrink: 0;
|
||||
padding: 4px;
|
||||
}
|
||||
|
||||
:deep(.pl-plan-product-cell-control) {
|
||||
.el-input__wrapper,
|
||||
.el-select__wrapper {
|
||||
min-height: 32px;
|
||||
font-size: 12px;
|
||||
}
|
||||
}
|
||||
|
||||
@media (max-width: 520px) {
|
||||
.pl-stop-product-dual-item__row1 {
|
||||
grid-template-columns: 1fr 1fr;
|
||||
}
|
||||
|
||||
.pl-stop-product-dual-item__product {
|
||||
grid-column: 1 / -1;
|
||||
}
|
||||
|
||||
.pl-stop-product-dual-item__row2 {
|
||||
grid-template-columns: 1fr 1fr;
|
||||
}
|
||||
|
||||
.pl-stop-product-dual-item__field--remark {
|
||||
grid-column: 1 / -1;
|
||||
}
|
||||
|
||||
.pl-stop-product-dual-item__act {
|
||||
grid-column: 2;
|
||||
justify-content: flex-end;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
|
||||
<style lang="scss">
|
||||
.pl-plan-alias-brand-select-dropdown {
|
||||
.el-select-dropdown__item {
|
||||
font-size: 12px;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
@@ -0,0 +1,333 @@
|
||||
<template>
|
||||
<div class="pl-plan-stops-split">
|
||||
<div class="pl-plan-stops-split__main">
|
||||
<div class="pl-plan-stops-split__pane pl-plan-stops-split__pane--load">
|
||||
<header class="pl-plan-stops-split__hd">
|
||||
<h4 class="pl-plan-stops-split__title">
|
||||
<span class="pl-plan-stops-split__dot pl-plan-stops-split__dot--load" />
|
||||
装货信息
|
||||
</h4>
|
||||
<div class="pl-plan-stops-split__hd-actions">
|
||||
<slot name="load-actions" />
|
||||
</div>
|
||||
</header>
|
||||
<div class="pl-plan-stops-split__bd">
|
||||
<slot name="load" />
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="pl-plan-flow-bridge" aria-hidden="true">
|
||||
<span class="pl-plan-flow-bridge__label">运输</span>
|
||||
<span class="pl-plan-flow-bridge__arrow">
|
||||
<svg viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg" aria-hidden="true">
|
||||
<path
|
||||
d="M5 12h11.5"
|
||||
stroke="currentColor"
|
||||
stroke-width="2.75"
|
||||
stroke-linecap="round"
|
||||
/>
|
||||
<path
|
||||
d="M13.5 8.5 18.5 12l-5 3.5"
|
||||
stroke="currentColor"
|
||||
stroke-width="2.75"
|
||||
stroke-linecap="round"
|
||||
stroke-linejoin="round"
|
||||
/>
|
||||
</svg>
|
||||
</span>
|
||||
</div>
|
||||
|
||||
<div class="pl-plan-stops-split__pane pl-plan-stops-split__pane--delivery">
|
||||
<header class="pl-plan-stops-split__hd">
|
||||
<h4 class="pl-plan-stops-split__title">
|
||||
<span class="pl-plan-stops-split__dot pl-plan-stops-split__dot--delivery" />
|
||||
送货信息
|
||||
</h4>
|
||||
<div class="pl-plan-stops-split__hd-actions">
|
||||
<slot name="delivery-actions" />
|
||||
</div>
|
||||
</header>
|
||||
<div class="pl-plan-stops-split__bd">
|
||||
<slot name="delivery" />
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<footer v-if="showBalance" class="pl-plan-stops-split__balance">
|
||||
<span class="pl-plan-stops-split__balance-item">
|
||||
计划总量 <strong>{{ formatQty(planTotalQty) }}{{ unitSuffix }}</strong>
|
||||
</span>
|
||||
<span class="pl-plan-stops-split__balance-item">
|
||||
装货合计 <strong>{{ formatQty(loadTotalQty) }}{{ unitSuffix }}</strong>
|
||||
</span>
|
||||
<span class="pl-plan-stops-split__balance-item">
|
||||
送货合计 <strong>{{ formatQty(deliveryTotalQty) }}{{ unitSuffix }}</strong>
|
||||
</span>
|
||||
<span
|
||||
class="pl-plan-stops-split__balance-status"
|
||||
:class="isBalanced ? 'is-ok' : 'is-warn'"
|
||||
>
|
||||
{{ isBalanced ? '✓ 数量平衡' : '数量不平衡(可暂存)' }}
|
||||
</span>
|
||||
<span v-if="deliveryBreakdown" class="pl-plan-stops-split__balance-extra">
|
||||
{{ deliveryBreakdown }}
|
||||
</span>
|
||||
</footer>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
const props = withDefaults(
|
||||
defineProps<{
|
||||
planTotalQty?: number
|
||||
loadTotalQty?: number
|
||||
deliveryTotalQty?: number
|
||||
unitLabel?: string
|
||||
showBalance?: boolean
|
||||
/** 送货各段数量摘要,如「10 + 15 + 5 = 30」 */
|
||||
deliveryBreakdown?: string
|
||||
qtyPrecision?: number
|
||||
}>(),
|
||||
{
|
||||
planTotalQty: 0,
|
||||
loadTotalQty: 0,
|
||||
deliveryTotalQty: 0,
|
||||
unitLabel: '',
|
||||
showBalance: true,
|
||||
deliveryBreakdown: '',
|
||||
qtyPrecision: 3
|
||||
}
|
||||
)
|
||||
|
||||
const unitSuffix = computed(() => (props.unitLabel ? props.unitLabel : ''))
|
||||
|
||||
const isBalanced = computed(() => {
|
||||
const plan = roundQty(props.planTotalQty)
|
||||
const load = roundQty(props.loadTotalQty)
|
||||
const delivery = roundQty(props.deliveryTotalQty)
|
||||
if (plan <= 0 && load <= 0 && delivery <= 0) return true
|
||||
return plan === load && load === delivery
|
||||
})
|
||||
|
||||
function roundQty(value: number) {
|
||||
const p = props.qtyPrecision
|
||||
return Number(Number(value || 0).toFixed(p))
|
||||
}
|
||||
|
||||
function formatQty(value: number) {
|
||||
const n = Number(value || 0)
|
||||
if (!Number.isFinite(n)) return '—'
|
||||
return String(parseFloat(n.toFixed(props.qtyPrecision)))
|
||||
}
|
||||
</script>
|
||||
|
||||
<style scoped lang="scss">
|
||||
.pl-plan-stops-split {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 10px;
|
||||
min-height: 360px;
|
||||
}
|
||||
|
||||
.pl-plan-stops-split__main {
|
||||
display: flex;
|
||||
align-items: stretch;
|
||||
flex: 1 1 auto;
|
||||
min-height: 0;
|
||||
gap: 0;
|
||||
}
|
||||
|
||||
.pl-plan-stops-split__pane {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
flex: 1 1 0;
|
||||
min-width: 0;
|
||||
min-height: 0;
|
||||
border: 1px solid #d9e8e2;
|
||||
border-radius: 10px;
|
||||
background: #fff;
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
.pl-plan-flow-bridge {
|
||||
flex: 0 0 88px;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
gap: 10px;
|
||||
padding: 0 8px;
|
||||
align-self: center;
|
||||
background: transparent;
|
||||
z-index: 1;
|
||||
}
|
||||
|
||||
.pl-plan-flow-bridge__label {
|
||||
font-size: 12px;
|
||||
font-weight: 600;
|
||||
color: var(--primary-dark, #168f45);
|
||||
letter-spacing: 0.06em;
|
||||
padding: 4px 10px;
|
||||
border-radius: 999px;
|
||||
background: #e6f8ed;
|
||||
border: 1px solid #a8e0b8;
|
||||
line-height: 1.2;
|
||||
}
|
||||
|
||||
.pl-plan-flow-bridge__arrow {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
width: 44px;
|
||||
height: 44px;
|
||||
border-radius: 50%;
|
||||
color: var(--primary-dark, #168f45);
|
||||
background: linear-gradient(145deg, #e6f8ed 0%, #d4f0de 100%);
|
||||
border: 1px solid #a8e0b8;
|
||||
box-shadow: 0 2px 8px rgba(28, 168, 81, 0.14);
|
||||
|
||||
svg {
|
||||
width: 22px;
|
||||
height: 22px;
|
||||
display: block;
|
||||
}
|
||||
}
|
||||
|
||||
.pl-plan-stops-split__hd {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
gap: 10px;
|
||||
height: 38px;
|
||||
min-height: 38px;
|
||||
padding: 0 12px;
|
||||
border-bottom: 1px solid #d9e8e2;
|
||||
flex-shrink: 0;
|
||||
box-sizing: border-box;
|
||||
}
|
||||
|
||||
.pl-plan-stops-split__hd-actions {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
flex-shrink: 0;
|
||||
min-height: 0;
|
||||
gap: 4px;
|
||||
|
||||
&:empty {
|
||||
display: none;
|
||||
}
|
||||
|
||||
:deep(.el-button) {
|
||||
height: 26px !important;
|
||||
padding: 0 8px !important;
|
||||
font-size: 12px;
|
||||
line-height: 1;
|
||||
border-radius: 6px;
|
||||
font-weight: 600;
|
||||
|
||||
.el-icon {
|
||||
font-size: 12px;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.pl-plan-stops-split__pane--load .pl-plan-stops-split__hd {
|
||||
background: linear-gradient(180deg, #ecfdf5 0%, #f8fffc 100%);
|
||||
}
|
||||
|
||||
.pl-plan-stops-split__pane--delivery .pl-plan-stops-split__hd {
|
||||
background: linear-gradient(180deg, #f0f9ff 0%, #f8fcff 100%);
|
||||
}
|
||||
|
||||
.pl-plan-stops-split__title {
|
||||
margin: 0;
|
||||
font-size: 13px;
|
||||
font-weight: 700;
|
||||
color: #1e293b;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 8px;
|
||||
line-height: 1;
|
||||
}
|
||||
|
||||
.pl-plan-stops-split__dot {
|
||||
width: 8px;
|
||||
height: 8px;
|
||||
border-radius: 50%;
|
||||
flex-shrink: 0;
|
||||
|
||||
&--load {
|
||||
background: #10b981;
|
||||
}
|
||||
|
||||
&--delivery {
|
||||
background: #0284c7;
|
||||
}
|
||||
}
|
||||
|
||||
.pl-plan-stops-split__bd {
|
||||
padding: 12px;
|
||||
flex: 1;
|
||||
min-height: 0;
|
||||
overflow: auto;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 8px;
|
||||
}
|
||||
|
||||
.pl-plan-stops-split__balance {
|
||||
flex: 0 0 auto;
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
align-items: center;
|
||||
gap: 10px 16px;
|
||||
padding: 8px 12px;
|
||||
border: 1px solid #d9e8e2;
|
||||
border-radius: 10px;
|
||||
background: #f8fafc;
|
||||
font-size: 12px;
|
||||
color: #64748b;
|
||||
}
|
||||
|
||||
.pl-plan-stops-split__balance-item strong {
|
||||
color: #1e293b;
|
||||
font-weight: 700;
|
||||
}
|
||||
|
||||
.pl-plan-stops-split__balance-status {
|
||||
font-weight: 600;
|
||||
|
||||
&.is-ok {
|
||||
color: #059669;
|
||||
}
|
||||
|
||||
&.is-warn {
|
||||
color: #d97706;
|
||||
}
|
||||
}
|
||||
|
||||
.pl-plan-stops-split__balance-extra {
|
||||
margin-left: auto;
|
||||
font-size: 11px;
|
||||
color: #94a3b8;
|
||||
}
|
||||
|
||||
@media (max-width: 1100px) {
|
||||
.pl-plan-stops-split__main {
|
||||
flex-direction: column;
|
||||
gap: 0;
|
||||
}
|
||||
|
||||
.pl-plan-flow-bridge {
|
||||
flex: 0 0 auto;
|
||||
flex-direction: row;
|
||||
gap: 12px;
|
||||
padding: 10px 0;
|
||||
align-self: center;
|
||||
}
|
||||
|
||||
.pl-plan-flow-bridge__arrow {
|
||||
transform: rotate(90deg);
|
||||
}
|
||||
}
|
||||
</style>
|
||||
@@ -77,6 +77,28 @@
|
||||
/>
|
||||
<span v-else class="pl-plan-form-empty-hint">—</span>
|
||||
</div>
|
||||
<div v-if="driverStopFeedbacks.length" class="pl-feedback-stop-list">
|
||||
<div
|
||||
v-for="row in driverStopFeedbacks"
|
||||
:key="`${row.stopType}-${row.stopId}`"
|
||||
class="pl-feedback-stop-item"
|
||||
>
|
||||
<div class="pl-feedback-stop-title">
|
||||
{{ row.label }} · {{ row.customerName }}
|
||||
</div>
|
||||
<AttachmentUploadField
|
||||
v-if="row.attachmentUrls?.length"
|
||||
class="pl-feedback-ticket-attach"
|
||||
:model-value="(row.attachmentUrls || []).join(',')"
|
||||
disabled
|
||||
compact
|
||||
folder="pl/transport/feedback"
|
||||
accept="image/*,video/*,.pdf"
|
||||
:limit="15"
|
||||
/>
|
||||
<span v-else class="pl-plan-form-empty-hint">暂无附件</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div v-if="feedbackEditable" class="pl-plan-feedback-card-footer">
|
||||
@@ -89,9 +111,9 @@
|
||||
<el-icon><Edit /></el-icon>
|
||||
{{ hasDriverFeedback ? '编辑' : '补充' }}
|
||||
</el-button>
|
||||
<el-button v-if="arrangeDriverUrl" class="btn-op-item" @click="emit('copy-driver-url')">
|
||||
<el-button v-if="arrangeDriverUrl" class="btn-op-item" @click="emit('copy-driver-summary')">
|
||||
<el-icon><CopyDocument /></el-icon>
|
||||
复制司机链接
|
||||
复制给司机
|
||||
</el-button>
|
||||
</div>
|
||||
</section>
|
||||
@@ -223,6 +245,35 @@
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div v-if="siteStopFeedbacks.length" class="pl-feedback-stop-list">
|
||||
<div
|
||||
v-for="row in siteStopFeedbacks"
|
||||
:key="`site-stop-${row.stopType}-${row.stopId}`"
|
||||
class="pl-feedback-stop-item"
|
||||
>
|
||||
<div class="pl-feedback-stop-title">
|
||||
{{ row.label }} · {{ row.customerName }}
|
||||
<span v-if="row.businessType" class="form-label-tip">({{ row.businessType }})</span>
|
||||
</div>
|
||||
<ViewKvGrid
|
||||
:fields="[
|
||||
{ label: '数量', value: row.quantity != null ? `${row.quantity} 吨` : '—' },
|
||||
{ label: '备注', value: row.remark || '—', fullSpan: true }
|
||||
]"
|
||||
:columns="2"
|
||||
/>
|
||||
<AttachmentUploadField
|
||||
v-if="row.attachmentUrls?.length"
|
||||
class="pl-feedback-ticket-attach"
|
||||
:model-value="(row.attachmentUrls || []).join(',')"
|
||||
disabled
|
||||
compact
|
||||
folder="pl/transport/site-feedback"
|
||||
accept="image/*,video/*,.pdf"
|
||||
:limit="15"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
</div>
|
||||
@@ -425,6 +476,26 @@
|
||||
ioOrderImageCsv?: string
|
||||
siteFeedbackTableRows?: SiteFeedbackTableRow[]
|
||||
dibangPlanRows?: PlPlanTransportDibangRow[]
|
||||
driverStopFeedbacks?: {
|
||||
stopType: string
|
||||
stopId: string
|
||||
label: string
|
||||
customerName: string
|
||||
attachmentUrls?: string[]
|
||||
remark?: string
|
||||
feedbackTime?: string
|
||||
}[]
|
||||
siteStopFeedbacks?: {
|
||||
stopType: string
|
||||
stopId: string
|
||||
label: string
|
||||
customerName: string
|
||||
businessType?: string
|
||||
quantity?: number
|
||||
attachmentUrls?: string[]
|
||||
remark?: string
|
||||
feedbackTime?: string
|
||||
}[]
|
||||
}>(),
|
||||
{
|
||||
feedbackEditable: false,
|
||||
@@ -448,7 +519,9 @@
|
||||
ioOrderViewFields: () => [],
|
||||
ioOrderImageCsv: '',
|
||||
siteFeedbackTableRows: () => [],
|
||||
dibangPlanRows: () => []
|
||||
dibangPlanRows: () => [],
|
||||
driverStopFeedbacks: () => [],
|
||||
siteStopFeedbacks: () => []
|
||||
}
|
||||
)
|
||||
|
||||
@@ -553,6 +626,7 @@
|
||||
const emit = defineEmits<{
|
||||
'edit-driver': []
|
||||
'copy-driver-url': []
|
||||
'copy-driver-summary': []
|
||||
'edit-io-order': []
|
||||
'copy-site-url': [url?: string]
|
||||
'edit-site-feedback': [row: SiteFeedbackTableRow]
|
||||
@@ -1064,4 +1138,25 @@
|
||||
max-height: 480px;
|
||||
}
|
||||
}
|
||||
|
||||
.pl-feedback-stop-list {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 10px;
|
||||
padding: 0 12px 12px;
|
||||
}
|
||||
|
||||
.pl-feedback-stop-item {
|
||||
padding: 10px 12px;
|
||||
border: 1px dashed #cbd5e1;
|
||||
border-radius: 8px;
|
||||
background: #f8fafc;
|
||||
}
|
||||
|
||||
.pl-feedback-stop-title {
|
||||
margin-bottom: 8px;
|
||||
font-size: 13px;
|
||||
font-weight: 600;
|
||||
color: #1e293b;
|
||||
}
|
||||
</style>
|
||||
@@ -13,10 +13,7 @@
|
||||
@closed="handleClosed"
|
||||
@opened="handleOpened"
|
||||
>
|
||||
<div
|
||||
v-if="$slots['hero-actions'] || showArrangeActions"
|
||||
class="pl-plan-view-hero-actions"
|
||||
>
|
||||
<div v-if="$slots['hero-actions'] || showArrangeActions" class="pl-plan-view-hero-actions">
|
||||
<template v-if="showArrangeActions">
|
||||
<el-button @click="copyPlanSummary()">
|
||||
<el-icon><CopyDocument /></el-icon>复制给司机
|
||||
@@ -49,145 +46,149 @@
|
||||
ref="qrcodeDialogRef"
|
||||
/>
|
||||
|
||||
<PlPlanPoundQrcodePickDialog
|
||||
v-model:visible="poundQrcodePickVisible"
|
||||
:records="poundQrcodePickRecords"
|
||||
:plan="arrangeActionPlan"
|
||||
@copy="handlePoundQrcodePickCopy"
|
||||
@preview="handlePoundQrcodePickPreview"
|
||||
/>
|
||||
</el-dialog>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { CopyDocument } from '@element-plus/icons-vue'
|
||||
import { planApi } from '@/api/pl'
|
||||
import DbPoundSlipQrcodeDialog from '@/components/business/db/DbPoundSlipQrcodeDialog.vue'
|
||||
import PlPlanViewTabs from '@/components/business/pl-plan-view-tabs/index.vue'
|
||||
import { usePlPlanArrangeActions } from '@/composables/usePlPlanArrangeActions'
|
||||
import { CopyDocument } from '@element-plus/icons-vue'
|
||||
import { planApi } from '@/api/pl'
|
||||
import DbPoundSlipQrcodeDialog from '@/components/business/db/DbPoundSlipQrcodeDialog.vue'
|
||||
import PlPlanPoundQrcodePickDialog from '@/components/business/pl-plan-pound-qrcode-pick-dialog/index.vue'
|
||||
import PlPlanViewTabs from '@/components/business/pl-plan-view-tabs/index.vue'
|
||||
import { usePlPlanArrangeActions } from '@/composables/usePlPlanArrangeActions'
|
||||
|
||||
const props = defineProps<{
|
||||
visible: boolean
|
||||
planId?: string
|
||||
/** 仅运输计划归档:展示入库/出库单价与金额 */
|
||||
showArchiveIoFields?: boolean
|
||||
/** 计划概况产品表:展示入库/出库数量(不含单价与金额) */
|
||||
showInboundOutboundQty?: boolean
|
||||
}>()
|
||||
const props = defineProps<{
|
||||
visible: boolean
|
||||
planId?: string
|
||||
/** 仅运输计划归档:展示入库/出库单价与金额 */
|
||||
showArchiveIoFields?: boolean
|
||||
/** 计划概况产品表:展示入库/出库数量(不含单价与金额) */
|
||||
showInboundOutboundQty?: boolean
|
||||
}>()
|
||||
|
||||
const emit = defineEmits<{
|
||||
'update:visible': [value: boolean]
|
||||
}>()
|
||||
const emit = defineEmits<{
|
||||
'update:visible': [value: boolean]
|
||||
}>()
|
||||
|
||||
const innerVisible = computed({
|
||||
get: () => props.visible,
|
||||
set: value => emit('update:visible', value)
|
||||
})
|
||||
const innerVisible = computed({
|
||||
get: () => props.visible,
|
||||
set: (value) => emit('update:visible', value)
|
||||
})
|
||||
|
||||
const tabsRef = ref<InstanceType<typeof PlPlanViewTabs> | null>(null)
|
||||
const planNo = ref('')
|
||||
const tabsRef = ref<InstanceType<typeof PlPlanViewTabs> | null>(null)
|
||||
const planNo = ref('')
|
||||
|
||||
const {
|
||||
showArrangeActions,
|
||||
hasSiteInventoryRecords,
|
||||
hasDibangInventoryRecords,
|
||||
driverUrl,
|
||||
siteRecords,
|
||||
qrcodeVisible,
|
||||
selectedInventoryId,
|
||||
selectedInventoryUnit,
|
||||
qrcodeDialogRef,
|
||||
resetArrangeActions,
|
||||
loadArrangeActions,
|
||||
copySiteSummary,
|
||||
copyPlanSummary,
|
||||
copyPoundSlipQrcode
|
||||
} = usePlPlanArrangeActions()
|
||||
const {
|
||||
plan: arrangeActionPlan,
|
||||
showArrangeActions,
|
||||
hasSiteInventoryRecords,
|
||||
hasDibangInventoryRecords,
|
||||
driverUrl,
|
||||
siteRecords,
|
||||
qrcodeVisible,
|
||||
selectedInventoryId,
|
||||
selectedInventoryUnit,
|
||||
qrcodeDialogRef,
|
||||
poundQrcodePickVisible,
|
||||
poundQrcodePickRecords,
|
||||
resetArrangeActions,
|
||||
loadArrangeActions,
|
||||
copySiteSummary,
|
||||
copyPlanSummary,
|
||||
copyPoundSlipQrcode,
|
||||
handlePoundQrcodePickCopy,
|
||||
handlePoundQrcodePickPreview
|
||||
} = usePlPlanArrangeActions()
|
||||
|
||||
const dialogTitle = computed(() =>
|
||||
planNo.value ? `查看运输计划 · ${planNo.value}` : '查看运输计划'
|
||||
)
|
||||
const dialogTitle = computed(() =>
|
||||
planNo.value ? `查看运输计划 · ${planNo.value}` : '查看运输计划'
|
||||
)
|
||||
|
||||
async function handleOpened() {
|
||||
if (!props.planId) return
|
||||
try {
|
||||
const res = await planApi.get(props.planId)
|
||||
const data = res.data ?? res
|
||||
planNo.value = data?.planNo || ''
|
||||
await loadArrangeActions(props.planId)
|
||||
} catch {
|
||||
innerVisible.value = false
|
||||
ElMessage.error('加载运输计划详情失败')
|
||||
async function handleOpened() {
|
||||
if (!props.planId) return
|
||||
try {
|
||||
const res = await planApi.get(props.planId)
|
||||
const data = res.data ?? res
|
||||
planNo.value = data?.planNo || ''
|
||||
await loadArrangeActions(props.planId)
|
||||
} catch {
|
||||
innerVisible.value = false
|
||||
ElMessage.error('加载运输计划详情失败')
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function handleClosed() {
|
||||
planNo.value = ''
|
||||
resetArrangeActions()
|
||||
}
|
||||
|
||||
async function reload() {
|
||||
if (!props.visible || !props.planId) return
|
||||
try {
|
||||
const res = await planApi.get(props.planId)
|
||||
const data = res.data ?? res
|
||||
planNo.value = data?.planNo || ''
|
||||
await loadArrangeActions(props.planId)
|
||||
await tabsRef.value?.reload()
|
||||
} catch {
|
||||
/* 查看弹窗仍打开时静默失败,避免打断用户 */
|
||||
function handleClosed() {
|
||||
planNo.value = ''
|
||||
resetArrangeActions()
|
||||
}
|
||||
}
|
||||
|
||||
defineExpose({ reload })
|
||||
async function reload() {
|
||||
if (!props.visible || !props.planId) return
|
||||
try {
|
||||
const res = await planApi.get(props.planId)
|
||||
const data = res.data ?? res
|
||||
planNo.value = data?.planNo || ''
|
||||
await loadArrangeActions(props.planId)
|
||||
await tabsRef.value?.reload()
|
||||
} catch {
|
||||
/* 查看弹窗仍打开时静默失败,避免打断用户 */
|
||||
}
|
||||
}
|
||||
|
||||
defineExpose({ reload })
|
||||
</script>
|
||||
|
||||
<style scoped lang="scss">
|
||||
.pl-plan-view-footer {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
gap: 8px;
|
||||
justify-content: flex-end;
|
||||
}
|
||||
.pl-plan-view-footer {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
gap: 8px;
|
||||
justify-content: flex-end;
|
||||
}
|
||||
|
||||
.pl-plan-view-hero-actions {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
align-items: center;
|
||||
justify-content: flex-end;
|
||||
gap: 8px;
|
||||
margin-bottom: 12px;
|
||||
}
|
||||
.pl-plan-view-hero-actions {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
align-items: center;
|
||||
justify-content: flex-end;
|
||||
gap: 8px;
|
||||
margin-bottom: 12px;
|
||||
}
|
||||
</style>
|
||||
|
||||
<style lang="scss">
|
||||
.el-dialog.pl-plan-view-dialog.dialog-form-layout {
|
||||
width: 100% !important;
|
||||
max-width: calc(100vw - 48px);
|
||||
height: var(--dialog-max-height, calc(100vh - 40px));
|
||||
max-height: var(--dialog-max-height, calc(100vh - 40px));
|
||||
}
|
||||
.el-dialog.pl-plan-view-dialog.dialog-form-layout {
|
||||
width: 100% !important;
|
||||
max-width: calc(100vw - 48px);
|
||||
height: var(--dialog-max-height, calc(100vh - 40px));
|
||||
max-height: var(--dialog-max-height, calc(100vh - 40px));
|
||||
}
|
||||
|
||||
.el-dialog.pl-plan-view-dialog.dialog-form-layout .el-dialog__body {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
flex: 1;
|
||||
min-height: 0;
|
||||
}
|
||||
.el-dialog.pl-plan-view-dialog.dialog-form-layout .el-dialog__body {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
flex: 1;
|
||||
min-height: 0;
|
||||
}
|
||||
|
||||
.el-dialog.pl-plan-view-dialog.dialog-form-layout .pl-plan-view-tabs {
|
||||
flex: 1;
|
||||
min-height: 0;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
}
|
||||
.el-dialog.pl-plan-view-dialog.dialog-form-layout .pl-plan-view-tabs {
|
||||
flex: 1;
|
||||
min-height: 0;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
}
|
||||
|
||||
.el-dialog.pl-plan-view-dialog.dialog-form-layout .pl-plan-view-tabs__nav.el-tabs {
|
||||
flex: 1;
|
||||
min-height: 0;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
}
|
||||
|
||||
.el-dialog.pl-plan-view-dialog.dialog-form-layout
|
||||
.pl-plan-view-tabs__nav.el-tabs
|
||||
> .el-tabs__content {
|
||||
flex: 1;
|
||||
min-height: 0;
|
||||
max-height: none;
|
||||
overflow-y: auto;
|
||||
}
|
||||
.el-dialog.pl-plan-view-dialog.dialog-form-layout .pl-plan-view-body {
|
||||
flex: 1;
|
||||
min-height: 0;
|
||||
max-height: none;
|
||||
overflow-y: auto;
|
||||
}
|
||||
</style>
|
||||
@@ -5,116 +5,18 @@
|
||||
class="pl-plan-view-tabs"
|
||||
:class="{ 'is-embedded': embedded, 'is-hide-nav': hideNav }"
|
||||
>
|
||||
<el-tabs v-model="activeTab" class="pl-plan-view-tabs__nav">
|
||||
<el-tab-pane label="计划概况" name="overview">
|
||||
<section class="pl-plan-form-section pl-plan-form-section--plain">
|
||||
<h3 class="pl-plan-form-section-title">基础信息</h3>
|
||||
<ViewKvTable :fields="overviewBasicViewFields" mode="sept" />
|
||||
</section>
|
||||
<div class="pl-plan-view-body">
|
||||
<section class="pl-plan-form-section pl-plan-form-section--plain">
|
||||
<h3 class="pl-plan-form-section-title">基础信息</h3>
|
||||
<ViewKvTable :fields="overviewBasicViewFields" mode="sept" />
|
||||
</section>
|
||||
|
||||
<section class="pl-plan-form-section pl-plan-form-section--plain">
|
||||
<h3 class="pl-plan-form-section-title">产品信息</h3>
|
||||
<p v-if="!productRows.length && !loading" class="pl-plan-form-empty-hint">暂无产品明细</p>
|
||||
<PlPlanFormProductTable
|
||||
v-else
|
||||
:products="productRows"
|
||||
show-actual-qty
|
||||
show-brand-qty
|
||||
:show-archive-io-fields="showArchiveIoFields"
|
||||
:show-inbound-outbound-qty="showInboundOutboundQty && !showArchiveIoFields"
|
||||
/>
|
||||
</section>
|
||||
|
||||
<section class="pl-plan-form-section pl-plan-form-section--plain">
|
||||
<h3 class="pl-plan-form-section-title">供需双方</h3>
|
||||
<div class="pl-plan-party-row">
|
||||
<div class="pl-plan-party-block">
|
||||
<h4 class="pl-plan-subtitle">供方信息</h4>
|
||||
<PlPlanContractMultiSelect
|
||||
:model-value="plan?.supplierContracts || []"
|
||||
:customer-id="plan?.supplierId"
|
||||
readonly
|
||||
>
|
||||
<template #toolbar>
|
||||
<div class="pl-plan-party-select-row">
|
||||
<div class="pl-plan-view-party-field pl-plan-party-select-row__customer">
|
||||
<span class="pl-plan-view-party-field__value">{{
|
||||
plan?.supplierName || '—'
|
||||
}}</span>
|
||||
<span
|
||||
v-if="supplierContactText"
|
||||
class="pl-plan-view-party-field__contact"
|
||||
>
|
||||
{{ supplierContactText }}
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
</PlPlanContractMultiSelect>
|
||||
</div>
|
||||
|
||||
<div class="pl-plan-flow-bridge" aria-hidden="true">
|
||||
<span class="pl-plan-flow-bridge__label">供货</span>
|
||||
<span class="pl-plan-flow-bridge__arrow">
|
||||
<svg viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg" aria-hidden="true">
|
||||
<path
|
||||
d="M5 12h11.5"
|
||||
stroke="currentColor"
|
||||
stroke-width="2.75"
|
||||
stroke-linecap="round"
|
||||
/>
|
||||
<path
|
||||
d="M13.5 8.5 18.5 12l-5 3.5"
|
||||
stroke="currentColor"
|
||||
stroke-width="2.75"
|
||||
stroke-linecap="round"
|
||||
stroke-linejoin="round"
|
||||
/>
|
||||
</svg>
|
||||
</span>
|
||||
</div>
|
||||
|
||||
<div class="pl-plan-party-block">
|
||||
<h4 class="pl-plan-subtitle">需方信息</h4>
|
||||
<PlPlanContractMultiSelect
|
||||
:model-value="plan?.demanderContracts || []"
|
||||
:customer-id="plan?.customerId"
|
||||
readonly
|
||||
>
|
||||
<template #toolbar>
|
||||
<div class="pl-plan-party-select-row">
|
||||
<div class="pl-plan-view-party-field pl-plan-party-select-row__customer">
|
||||
<span class="pl-plan-view-party-field__value">{{
|
||||
plan?.customerName || '—'
|
||||
}}</span>
|
||||
<span
|
||||
v-if="demanderContactText"
|
||||
class="pl-plan-view-party-field__contact"
|
||||
>
|
||||
{{ demanderContactText }}
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
</PlPlanContractMultiSelect>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<section class="pl-plan-form-section pl-plan-form-section--plain">
|
||||
<h3 class="pl-plan-form-section-title">危化品证书信息</h3>
|
||||
<PlPlanHazardCertViewTable :products="hazardProducts" />
|
||||
</section>
|
||||
|
||||
<section class="pl-plan-form-section pl-plan-form-section--plain">
|
||||
<h3 class="pl-plan-form-section-title">备注</h3>
|
||||
<p class="pl-plan-view-remark">{{ plan?.remark || '—' }}</p>
|
||||
</section>
|
||||
</el-tab-pane>
|
||||
|
||||
<el-tab-pane label="运输信息" name="transport">
|
||||
<section v-if="showArrangeLinks" class="pl-plan-form-section pl-plan-form-section--plain pl-plan-arrange-links">
|
||||
<h3 class="pl-plan-form-section-title">运输链接</h3>
|
||||
<section class="pl-plan-form-section pl-plan-form-section--plain">
|
||||
<h3 class="pl-plan-form-section-title">运输信息</h3>
|
||||
<div
|
||||
v-if="showArrangeLinks"
|
||||
class="pl-plan-arrange-links pl-plan-transport-block"
|
||||
>
|
||||
<div class="pl-arrange-links-body">
|
||||
<div class="pl-arrange-link-row">
|
||||
<span class="pl-arrange-link-label">司机链接</span>
|
||||
@@ -138,7 +40,9 @@
|
||||
:key="record.siteLinkId"
|
||||
class="pl-arrange-link-row"
|
||||
>
|
||||
<span class="pl-arrange-link-label">{{ record.productName || '现场链接' }}</span>
|
||||
<span class="pl-arrange-link-label">{{
|
||||
record.productName || '现场链接'
|
||||
}}</span>
|
||||
<el-input :model-value="record.siteUrl || ''" readonly />
|
||||
<el-button @click="copyArrangeSiteUrl(record.siteUrl)">
|
||||
<el-icon><CopyDocument /></el-icon>复制链接
|
||||
@@ -147,76 +51,188 @@
|
||||
</template>
|
||||
</template>
|
||||
<p
|
||||
v-else-if="showArrangeLinks && planSupportsInventory"
|
||||
v-else-if="showArrangeLinks && planRequiresSiteLinkFlag"
|
||||
class="pl-plan-form-empty-hint pl-plan-arrange-links-hint"
|
||||
>
|
||||
暂无现场链接
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
</div>
|
||||
|
||||
<section class="pl-plan-form-section pl-plan-form-section--plain">
|
||||
<h3 class="pl-plan-form-section-title">车辆信息</h3>
|
||||
<PlVehicleSummaryStrip
|
||||
v-if="vehicleBundle"
|
||||
:detail="vehicleBundle.detail"
|
||||
:personnel-list="vehicleBundle.personnelList"
|
||||
:carrier-name="summaryCarrierName"
|
||||
@view="vehicleViewVisible = true"
|
||||
/>
|
||||
<p v-else-if="!loading" class="pl-plan-form-empty-hint">暂无车辆信息</p>
|
||||
</section>
|
||||
|
||||
<section class="pl-plan-form-section pl-plan-form-section--plain">
|
||||
<h3 class="pl-plan-form-section-title">物流节点</h3>
|
||||
<div class="parties-row">
|
||||
<div class="party-panel party-panel--plain pl-plan-logistics-panel">
|
||||
<ViewKvTable :fields="pickupViewFields" mode="dual" />
|
||||
</div>
|
||||
|
||||
<div class="party-flow-bridge">
|
||||
<span class="party-flow-bridge__label">运输</span>
|
||||
<span class="party-flow-bridge__arrow">
|
||||
<svg viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg" aria-hidden="true">
|
||||
<path
|
||||
d="M5 12h11.5"
|
||||
stroke="currentColor"
|
||||
stroke-width="2.75"
|
||||
stroke-linecap="round"
|
||||
/>
|
||||
<path
|
||||
d="M13.5 8.5 18.5 12l-5 3.5"
|
||||
stroke="currentColor"
|
||||
stroke-width="2.75"
|
||||
stroke-linecap="round"
|
||||
stroke-linejoin="round"
|
||||
/>
|
||||
</svg>
|
||||
</span>
|
||||
</div>
|
||||
|
||||
<div class="party-panel party-panel--plain pl-plan-logistics-panel">
|
||||
<ViewKvTable :fields="deliveryViewFields" mode="dual" />
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<section class="pl-plan-form-section pl-plan-form-section--plain">
|
||||
<h3 class="pl-plan-form-section-title">运费信息</h3>
|
||||
<ViewKvTable :fields="freightViewFields" mode="sept" />
|
||||
</section>
|
||||
|
||||
<PlPlanTransportFeedbackBlocks
|
||||
v-if="!feedbackMirrorTo"
|
||||
v-bind="feedbackBlocksBind"
|
||||
v-on="feedbackBlocksOn"
|
||||
<PlVehicleSummaryStrip
|
||||
v-if="vehicleBundle"
|
||||
class="pl-plan-transport-block"
|
||||
:detail="vehicleBundle.detail"
|
||||
:personnel-list="vehicleBundle.personnelList"
|
||||
:carrier-name="summaryCarrierName"
|
||||
@view="vehicleViewVisible = true"
|
||||
/>
|
||||
</el-tab-pane>
|
||||
<p v-else-if="!loading" class="pl-plan-form-empty-hint">暂无车辆信息</p>
|
||||
</section>
|
||||
|
||||
</el-tabs>
|
||||
<section class="pl-plan-form-section pl-plan-form-section--plain">
|
||||
<h3 class="pl-plan-form-section-title">装送货信息</h3>
|
||||
<PlPlanStopsSplitShell
|
||||
:plan-total-qty="viewPlanTotalQty"
|
||||
:load-total-qty="viewLoadTotalQty"
|
||||
:delivery-total-qty="viewDeliveryTotalQty"
|
||||
:unit-label="viewQtyUnitLabel"
|
||||
:delivery-breakdown="viewDeliveryQtyBreakdown"
|
||||
>
|
||||
<template #load>
|
||||
<div class="pl-plan-view-stop-block">
|
||||
<div class="pl-plan-view-stop-meta">
|
||||
<div class="pl-plan-view-party-field">
|
||||
<span class="pl-plan-view-party-field__label">装货客户</span>
|
||||
<span class="pl-plan-view-party-field__value">{{
|
||||
loadView.customerName || '—'
|
||||
}}</span>
|
||||
</div>
|
||||
<div class="pl-plan-view-party-field">
|
||||
<span class="pl-plan-view-party-field__label">装货时间</span>
|
||||
<span class="pl-plan-view-party-field__value">{{
|
||||
formatViewDate(loadView.loadTime)
|
||||
}}</span>
|
||||
</div>
|
||||
<div class="pl-plan-view-party-field">
|
||||
<span class="pl-plan-view-party-field__label">装货地址</span>
|
||||
<span class="pl-plan-view-party-field__value">{{ loadView.address || '—' }}</span>
|
||||
</div>
|
||||
<div v-if="loadView.contact" class="pl-plan-view-party-field">
|
||||
<span class="pl-plan-view-party-field__label">联系方式</span>
|
||||
<span class="pl-plan-view-party-field__value">{{ loadView.contact }}</span>
|
||||
</div>
|
||||
<div v-if="loadView.notes" class="pl-plan-view-party-field">
|
||||
<span class="pl-plan-view-party-field__label">注意事项</span>
|
||||
<span class="pl-plan-view-party-field__value">{{ loadView.notes }}</span>
|
||||
</div>
|
||||
</div>
|
||||
<PlPlanContractMultiSelect
|
||||
:model-value="loadView.contracts || []"
|
||||
:customer-id="loadView.customerId"
|
||||
readonly
|
||||
compact-summary
|
||||
/>
|
||||
<PlPlanStopProductTable
|
||||
v-if="loadView.products?.length"
|
||||
:products="loadView.products"
|
||||
compact
|
||||
show-stop-actual-qty
|
||||
:show-stop-archive-price="showArchiveIoFields"
|
||||
stop-archive-mode="load"
|
||||
/>
|
||||
<p v-else class="pl-plan-form-empty-hint">暂无装货产品</p>
|
||||
<PlPlanStopFeedbackPanel
|
||||
v-if="showStopFeedback && !feedbackMirrorTo"
|
||||
stop-label="装货"
|
||||
:customer-name="loadView.customerName"
|
||||
:generate-dibang="loadView.generateDibang"
|
||||
:dibang-rows="loadDibangRows"
|
||||
:driver-feedback="resolveDriverStopFeedback('load', loadStopId)"
|
||||
:site-feedback="resolveSiteStopFeedback('load', loadStopId)"
|
||||
:fallback-remark="transport?.feedbackRemark"
|
||||
/>
|
||||
</div>
|
||||
</template>
|
||||
<template #delivery>
|
||||
<div v-if="deliveryViews.length > 1" class="pl-plan-delivery-tabs pl-plan-view-delivery-tabs">
|
||||
<button
|
||||
v-for="(delivery, index) in deliveryViews"
|
||||
:key="delivery.id || 'delivery-tab-' + index"
|
||||
type="button"
|
||||
class="pl-plan-delivery-tab"
|
||||
:class="{ 'is-active': deliveryViewActiveIndex === index }"
|
||||
@click="deliveryViewActiveIndex = index"
|
||||
>
|
||||
#{{ delivery.seq || index + 1 }}
|
||||
{{ delivery.customerName || '未选客户' }}
|
||||
<span v-if="viewDeliveryQtyLabel(delivery)" class="pl-plan-delivery-tab__qty">
|
||||
{{ viewDeliveryQtyLabel(delivery) }}
|
||||
</span>
|
||||
</button>
|
||||
</div>
|
||||
<article
|
||||
v-for="(delivery, index) in deliveryViews"
|
||||
v-show="deliveryViews.length <= 1 || deliveryViewActiveIndex === index"
|
||||
:key="delivery.id || 'delivery-' + index"
|
||||
class="pl-plan-view-delivery-block"
|
||||
>
|
||||
<div class="pl-plan-view-stop-meta">
|
||||
<div class="pl-plan-view-party-field">
|
||||
<span class="pl-plan-view-party-field__label">送货客户</span>
|
||||
<span class="pl-plan-view-party-field__value">{{
|
||||
delivery.customerName || '—'
|
||||
}}</span>
|
||||
</div>
|
||||
<div class="pl-plan-view-party-field">
|
||||
<span class="pl-plan-view-party-field__label">送货时间</span>
|
||||
<span class="pl-plan-view-party-field__value">{{
|
||||
formatViewDate(delivery.deliveryTime)
|
||||
}}</span>
|
||||
</div>
|
||||
<div class="pl-plan-view-party-field">
|
||||
<span class="pl-plan-view-party-field__label">送货地址</span>
|
||||
<span class="pl-plan-view-party-field__value">{{ delivery.address || '—' }}</span>
|
||||
</div>
|
||||
<div v-if="delivery.contact" class="pl-plan-view-party-field">
|
||||
<span class="pl-plan-view-party-field__label">联系方式</span>
|
||||
<span class="pl-plan-view-party-field__value">{{ delivery.contact }}</span>
|
||||
</div>
|
||||
<div v-if="delivery.notes" class="pl-plan-view-party-field">
|
||||
<span class="pl-plan-view-party-field__label">注意事项</span>
|
||||
<span class="pl-plan-view-party-field__value">{{ delivery.notes }}</span>
|
||||
</div>
|
||||
</div>
|
||||
<PlPlanContractMultiSelect
|
||||
:model-value="delivery.contracts || []"
|
||||
:customer-id="delivery.customerId"
|
||||
readonly
|
||||
compact-summary
|
||||
/>
|
||||
<PlPlanStopProductTable
|
||||
v-if="delivery.products?.length"
|
||||
:products="delivery.products"
|
||||
compact
|
||||
show-stop-actual-qty
|
||||
:show-stop-archive-price="showArchiveIoFields"
|
||||
stop-archive-mode="delivery"
|
||||
/>
|
||||
<p v-else class="pl-plan-form-empty-hint">暂无送货产品</p>
|
||||
<PlPlanStopFeedbackPanel
|
||||
v-if="showStopFeedback && !feedbackMirrorTo"
|
||||
:stop-label="
|
||||
deliveryViews.length > 1 ? `送货 #${delivery.seq || index + 1}` : '送货'
|
||||
"
|
||||
:customer-name="delivery.customerName"
|
||||
:generate-dibang="delivery.generateDibang"
|
||||
:dibang-rows="resolveDeliveryDibangRows(delivery)"
|
||||
:driver-feedback="resolveDriverStopFeedback('delivery', delivery.id || '')"
|
||||
:site-feedback="resolveSiteStopFeedback('delivery', delivery.id || '')"
|
||||
:fallback-remark="transport?.feedbackRemark"
|
||||
/>
|
||||
</article>
|
||||
</template>
|
||||
</PlPlanStopsSplitShell>
|
||||
</section>
|
||||
|
||||
<!-- defer:目标在同次渲染的兄弟节点(归档左侧)时,等 flush 后再解析,避免 emitsOptions 空引用 -->
|
||||
<section class="pl-plan-form-section pl-plan-form-section--plain">
|
||||
<h3 class="pl-plan-form-section-title">危化品证书信息</h3>
|
||||
<PlPlanHazardCertViewTable :products="hazardProducts" />
|
||||
</section>
|
||||
|
||||
<section class="pl-plan-form-section pl-plan-form-section--plain">
|
||||
<h3 class="pl-plan-form-section-title">运费信息</h3>
|
||||
<ViewKvTable :fields="freightViewFields" mode="sept" />
|
||||
</section>
|
||||
|
||||
<section class="pl-plan-form-section pl-plan-form-section--plain">
|
||||
<h3 class="pl-plan-form-section-title">备注</h3>
|
||||
<p class="pl-plan-view-remark">{{ plan?.remark || '—' }}</p>
|
||||
</section>
|
||||
</div>
|
||||
|
||||
<!-- 归档左侧仍镜像旧回传区块;查看弹窗内改为按装/送货段展示 -->
|
||||
<Teleport v-if="feedbackMirrorTo" :to="feedbackMirrorTo" defer>
|
||||
<PlPlanTransportFeedbackBlocks v-bind="feedbackBlocksBind" v-on="feedbackBlocksOn" />
|
||||
</Teleport>
|
||||
@@ -375,8 +391,10 @@
|
||||
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'
|
||||
import PlPlanStopFeedbackPanel from '@/components/business/pl-plan-stop-feedback-panel/index.vue'
|
||||
import PlPlanStopProductTable from '@/components/business/pl-plan-stop-product-table/index.vue'
|
||||
import PlPlanStopsSplitShell from '@/components/business/pl-plan-stops-split-shell/index.vue'
|
||||
import PlPlanSiteFeedbackDialog from '@/components/business/pl-plan-site-feedback-dialog/index.vue'
|
||||
import PlPlanTransportFeedbackBlocks, {
|
||||
type SiteFeedbackTableRow
|
||||
@@ -386,9 +404,6 @@
|
||||
import ViewKvTable from '@/components/business/system-view-dialog/ViewKvTable.vue'
|
||||
import type { ViewField } from '@/components/business/system-view-dialog/types'
|
||||
import type { ContractVO } from '@/api/crm/contract/types'
|
||||
import { getContactByCustomerId } from '@/api/crm/customer'
|
||||
import type { ContactVO } from '@/api/crm/customerTypes'
|
||||
import { inventoryApi } from '@/api/db/inventory'
|
||||
import {
|
||||
inboundOrderApi,
|
||||
outboundOrderApi,
|
||||
@@ -401,15 +416,35 @@
|
||||
getDeliveryMethodLabel,
|
||||
type PlanFormProductRow
|
||||
} from '@/composables/usePlContractToPlan'
|
||||
import { mapPlanProductToFormRow, usePlPlanViewDetail, type PlPlanTransportSiteRow } from '@/composables/usePlPlanViewDetail'
|
||||
import {
|
||||
mapPlanProductToFormRow,
|
||||
usePlPlanViewDetail,
|
||||
type PlPlanTransportDibangRow,
|
||||
type PlPlanTransportSiteRow
|
||||
} from '@/composables/usePlPlanViewDetail'
|
||||
import {
|
||||
mapDeliveriesFromApi,
|
||||
mapLegacyPlanToStops,
|
||||
mapLoadFromApi,
|
||||
resolveDeliveryViewAddress,
|
||||
resolveLoadViewAddress,
|
||||
resolveStopProductsForView,
|
||||
sumStopProductsPlanQty,
|
||||
type PlanLoadForm,
|
||||
type PlanStopProductFormRow
|
||||
} from '@/utils/pl-plan-stop-form'
|
||||
import { resolveFreightUnitLabel } from '@/composables/usePlFreightCalc'
|
||||
import { isHazardProduct } from '@/composables/usePlToxicProductCertCheck'
|
||||
import { useDictStore } from '@/store/modules/dict'
|
||||
import { formatDate, formatDateTime } from '@/utils/format'
|
||||
import { pickBxData } from '@/utils/http/bx'
|
||||
import {
|
||||
buildSiteSummaryFromInventoryLinks
|
||||
buildSiteSummaryFromInventoryLinks,
|
||||
buildSiteStopBlocksFromPlan
|
||||
} from '@/utils/db-site-summary'
|
||||
import {
|
||||
buildDriverSummaryFromPlan,
|
||||
buildDriverStopBlocksFromPlan
|
||||
} from '@/utils/pl-driver-summary'
|
||||
import {
|
||||
formatPlanProductListText,
|
||||
formatBrandQtySummary,
|
||||
@@ -421,6 +456,7 @@
|
||||
parsePlFeedbackImages
|
||||
} from '@/utils/pl-display'
|
||||
import { formatMoneyDisplay } from '@/utils/money-format'
|
||||
import { planRequiresSiteLink } from '@/utils/pl-internal-customer'
|
||||
import type { Transport, TransportDriverProductFeedback } from '@/api/pl'
|
||||
|
||||
const dictStore = useDictStore()
|
||||
@@ -508,80 +544,6 @@
|
||||
resetDetail
|
||||
} = usePlPlanViewDetail()
|
||||
|
||||
type PartyContactDisplay = { contactName?: string; phone?: string }
|
||||
const supplierContact = ref<PartyContactDisplay>({})
|
||||
const demanderContact = ref<PartyContactDisplay>({})
|
||||
let partyContactLoadSeq = 0
|
||||
|
||||
function pickPrimaryContact(list: ContactVO[]): PartyContactDisplay {
|
||||
if (!list.length) return {}
|
||||
const primary =
|
||||
list.find(item => Number(item.isPrimary) === 1) ||
|
||||
list.find(item => Number(item.isKey) === 1) ||
|
||||
list[0]
|
||||
const contactName = String(primary?.contactName || '').trim()
|
||||
const phone = String(primary?.mobile || primary?.telephone || '').trim()
|
||||
return {
|
||||
contactName: contactName || undefined,
|
||||
phone: phone || undefined
|
||||
}
|
||||
}
|
||||
|
||||
function formatPartyContactText(contact: PartyContactDisplay): string {
|
||||
const parts: string[] = []
|
||||
if (contact.contactName) parts.push(contact.contactName)
|
||||
if (contact.phone) parts.push(contact.phone)
|
||||
return parts.join(' ')
|
||||
}
|
||||
|
||||
const supplierContactText = computed(() => formatPartyContactText(supplierContact.value))
|
||||
const demanderContactText = computed(() => formatPartyContactText(demanderContact.value))
|
||||
|
||||
async function loadPartyContact(customerId?: string | null): Promise<PartyContactDisplay> {
|
||||
const id = String(customerId || '').trim()
|
||||
if (!id) return {}
|
||||
try {
|
||||
const res = await getContactByCustomerId(id)
|
||||
const list = (res?.data || []) as ContactVO[]
|
||||
return pickPrimaryContact(Array.isArray(list) ? list : [])
|
||||
} catch {
|
||||
return {}
|
||||
}
|
||||
}
|
||||
|
||||
async function refreshPartyContacts() {
|
||||
const seq = ++partyContactLoadSeq
|
||||
const supplierId = plan.value?.supplierId
|
||||
const customerId = plan.value?.customerId
|
||||
const [supplier, demanderFromCrm] = await Promise.all([
|
||||
loadPartyContact(supplierId),
|
||||
loadPartyContact(customerId)
|
||||
])
|
||||
if (seq !== partyContactLoadSeq) return
|
||||
|
||||
supplierContact.value = supplier
|
||||
|
||||
const planContactName = String(plan.value?.contactName || '').trim()
|
||||
const planContactPhone = String(plan.value?.contactPhone || '').trim()
|
||||
demanderContact.value = {
|
||||
contactName: demanderFromCrm.contactName || planContactName || undefined,
|
||||
phone: demanderFromCrm.phone || planContactPhone || undefined
|
||||
}
|
||||
}
|
||||
|
||||
watch(
|
||||
() => [plan.value?.id, plan.value?.supplierId, plan.value?.customerId] as const,
|
||||
() => {
|
||||
if (!plan.value?.id) {
|
||||
supplierContact.value = {}
|
||||
demanderContact.value = {}
|
||||
return
|
||||
}
|
||||
void refreshPartyContacts()
|
||||
},
|
||||
{ immediate: true }
|
||||
)
|
||||
|
||||
const ioOrderEditVisible = ref(false)
|
||||
const ioOrderSaving = ref(false)
|
||||
const driverImagesSaving = ref(false)
|
||||
@@ -1156,10 +1118,7 @@
|
||||
() => props.showArrangeLinks && (props.arrangeSiteRecords?.length ?? 0) > 0
|
||||
)
|
||||
|
||||
const planSupportsInventory = computed(() => {
|
||||
const planType = plan.value?.planType
|
||||
return planType === 'inbound' || planType === 'outbound'
|
||||
})
|
||||
const planRequiresSiteLinkFlag = computed(() => planRequiresSiteLink(plan.value))
|
||||
|
||||
async function copyArrangeDriverUrl() {
|
||||
const url = props.arrangeDriverUrl?.trim()
|
||||
@@ -1171,6 +1130,29 @@
|
||||
ElMessage.success('已复制司机链接')
|
||||
}
|
||||
|
||||
async function copyDriverSummaryForArrange() {
|
||||
const url = props.arrangeDriverUrl?.trim()
|
||||
if (!url) {
|
||||
ElMessage.warning('暂无司机链接')
|
||||
return
|
||||
}
|
||||
const getUnitLabel = (unit: string) => dictStore.getLabel('crm_product_unit', unit) || unit
|
||||
const text = buildDriverSummaryFromPlan({
|
||||
plan: plan.value || undefined,
|
||||
planNo: plan.value?.planNo,
|
||||
licensePlate: plan.value?.licensePlate || transport.value?.licensePlate,
|
||||
pickupTime: plan.value?.pickupTime,
|
||||
planDate: plan.value?.planDate,
|
||||
personnelSummary: plan.value?.personnelSummary,
|
||||
driverUrl: url,
|
||||
products: products.value,
|
||||
getUnitLabel,
|
||||
stopBlocks: buildDriverStopBlocksFromPlan(plan.value, getUnitLabel)
|
||||
})
|
||||
await navigator.clipboard.writeText(text)
|
||||
ElMessage.success('已复制给司机')
|
||||
}
|
||||
|
||||
async function copyArrangeSiteUrl(url?: string) {
|
||||
const target = url?.trim()
|
||||
if (!target) {
|
||||
@@ -1198,7 +1180,8 @@
|
||||
licensePlate: plan.value?.licensePlate || transport.value?.licensePlate,
|
||||
pickupTime: plan.value?.pickupTime,
|
||||
planDate: plan.value?.planDate,
|
||||
records: [{ ...row.link, siteUrl: url, productText }]
|
||||
records: [{ ...row.link, siteUrl: url, productText }],
|
||||
stopBlocks: buildSiteStopBlocksFromPlan(plan.value)
|
||||
})
|
||||
await navigator.clipboard.writeText(text)
|
||||
ElMessage.success('已复制给现场')
|
||||
@@ -1206,6 +1189,155 @@
|
||||
|
||||
const displayFeedbackTime = computed(() => formatDateTime(transport.value?.feedbackTime) || '—')
|
||||
|
||||
const deliveryViewActiveIndex = ref(0)
|
||||
|
||||
const loadView = computed<PlanLoadForm & { id?: string }>(() => {
|
||||
if (plan.value?.load) {
|
||||
const mapped = mapLoadFromApi(plan.value.load)
|
||||
return {
|
||||
id: plan.value.load.id,
|
||||
...mapped,
|
||||
address: resolveLoadViewAddress(plan.value, mapped),
|
||||
products: resolveStopProductsForView(mapped.products, productRows.value)
|
||||
}
|
||||
}
|
||||
const legacy = mapLegacyPlanToStops(plan.value || ({} as any))
|
||||
return {
|
||||
id: undefined,
|
||||
...legacy.load,
|
||||
address: resolveLoadViewAddress(plan.value, legacy.load),
|
||||
products: resolveStopProductsForView(legacy.load.products, productRows.value)
|
||||
}
|
||||
})
|
||||
|
||||
const deliveryViews = computed(() => {
|
||||
if (plan.value?.deliveries?.length) {
|
||||
return mapDeliveriesFromApi(plan.value.deliveries, plan.value.load?.customerName).map((row, index) => ({
|
||||
id: plan.value?.deliveries?.[index]?.id,
|
||||
...row,
|
||||
address: resolveDeliveryViewAddress(plan.value, row, index),
|
||||
products: resolveStopProductsForView(row.products, productRows.value)
|
||||
}))
|
||||
}
|
||||
return mapLegacyPlanToStops(plan.value || ({} as any)).deliveries.map((row, index) => ({
|
||||
id: undefined as string | undefined,
|
||||
...row,
|
||||
address: resolveDeliveryViewAddress(plan.value, row, index),
|
||||
products: resolveStopProductsForView(row.products, productRows.value)
|
||||
}))
|
||||
})
|
||||
|
||||
watch(
|
||||
() => deliveryViews.value.length,
|
||||
(len) => {
|
||||
if (deliveryViewActiveIndex.value > Math.max(0, len - 1)) {
|
||||
deliveryViewActiveIndex.value = 0
|
||||
}
|
||||
}
|
||||
)
|
||||
|
||||
watch(
|
||||
() => props.planId,
|
||||
() => {
|
||||
deliveryViewActiveIndex.value = 0
|
||||
}
|
||||
)
|
||||
|
||||
const loadStopId = computed(() => String(plan.value?.load?.id || loadView.value.id || ''))
|
||||
|
||||
const viewPlanTotalQty = computed(() =>
|
||||
productRows.value.reduce((sum, row) => sum + Number(row.quantity ?? 0), 0)
|
||||
)
|
||||
const viewLoadTotalQty = computed(() => sumStopProductsPlanQty(loadView.value.products || []))
|
||||
const viewDeliveryTotalQty = computed(() =>
|
||||
deliveryViews.value.reduce((sum, row) => sum + sumStopProductsPlanQty(row.products || []), 0)
|
||||
)
|
||||
const viewQtyUnitLabel = computed(() => resolveFreightUnitLabel(productRows.value))
|
||||
const viewDeliveryQtyBreakdown = computed(() => {
|
||||
const parts = deliveryViews.value
|
||||
.map((row) => parseFloat(sumStopProductsPlanQty(row.products || []).toFixed(3)))
|
||||
.filter((qty) => qty > 0)
|
||||
if (parts.length < 2) return ''
|
||||
const total = parseFloat(parts.reduce((a, b) => a + b, 0).toFixed(3))
|
||||
return `${parts.join(' + ')} = ${total}`
|
||||
})
|
||||
|
||||
function formatViewDate(value?: string | null) {
|
||||
if (!value) return '—'
|
||||
return formatDate(value) || String(value).slice(0, 10) || '—'
|
||||
}
|
||||
|
||||
function viewDeliveryQtyLabel(delivery: { products?: PlanStopProductFormRow[] }) {
|
||||
const qty = sumStopProductsPlanQty(delivery.products || [])
|
||||
if (qty <= 0) return ''
|
||||
const unit = viewQtyUnitLabel.value || ''
|
||||
const text = String(parseFloat(qty.toFixed(3)))
|
||||
return unit ? `${text}${unit}` : text
|
||||
}
|
||||
|
||||
function collectStopProductIds(products: PlanStopProductFormRow[]) {
|
||||
return products.map((row) => String(row.planProductId || '').trim()).filter(Boolean)
|
||||
}
|
||||
|
||||
function resolveStopDibangRows(
|
||||
stopType: 'load' | 'delivery',
|
||||
stopId: string,
|
||||
productIds: string[]
|
||||
): PlPlanTransportDibangRow[] {
|
||||
return dibangRows.value.filter((row) => {
|
||||
const link = row.link
|
||||
if (link.stopType && link.stopId) {
|
||||
return link.stopType === stopType && link.stopId === stopId
|
||||
}
|
||||
if (productIds.length && link.planProductId) {
|
||||
return productIds.includes(String(link.planProductId))
|
||||
}
|
||||
return false
|
||||
})
|
||||
}
|
||||
|
||||
const loadDibangRows = computed(() =>
|
||||
resolveStopDibangRows(
|
||||
'load',
|
||||
loadStopId.value,
|
||||
collectStopProductIds(loadView.value.products || [])
|
||||
)
|
||||
)
|
||||
|
||||
function resolveDeliveryDibangRows(delivery: {
|
||||
id?: string
|
||||
products?: PlanStopProductFormRow[]
|
||||
}) {
|
||||
return resolveStopDibangRows(
|
||||
'delivery',
|
||||
delivery.id || '',
|
||||
collectStopProductIds(delivery.products || [])
|
||||
)
|
||||
}
|
||||
|
||||
function resolveDriverStopFeedback(stopType: 'load' | 'delivery', stopId: string) {
|
||||
if (!stopId) return null
|
||||
return (
|
||||
transport.value?.driverStopFeedbacks?.find(
|
||||
(item) => item.stopType === stopType && item.stopId === stopId
|
||||
) || null
|
||||
)
|
||||
}
|
||||
|
||||
function resolveSiteStopFeedback(stopType: 'load' | 'delivery', stopId: string) {
|
||||
if (!stopId) return null
|
||||
return (
|
||||
transport.value?.siteStopFeedbacks?.find(
|
||||
(item) => item.stopType === stopType && item.stopId === stopId
|
||||
) || null
|
||||
)
|
||||
}
|
||||
|
||||
const showStopFeedback = computed(
|
||||
() => plan.value?.transportStatus === 'arranged' && plan.value?.followStatus !== 'cancelled'
|
||||
)
|
||||
|
||||
|
||||
const feedbackBlocksBind = computed(() => ({
|
||||
feedbackEditable: props.feedbackEditable,
|
||||
showArchiveIoFields: props.showArchiveIoFields,
|
||||
@@ -1236,6 +1368,9 @@
|
||||
const feedbackBlocksOn = {
|
||||
'edit-driver': openDriverFeedbackDialog,
|
||||
'copy-driver-url': copyArrangeDriverUrl,
|
||||
'copy-driver-summary': () => {
|
||||
void copyDriverSummaryForArrange()
|
||||
},
|
||||
'edit-io-order': openIoOrderEditDialog,
|
||||
'save-driver-images': (csv: string) => {
|
||||
void saveDriverImagesInline(csv)
|
||||
@@ -1304,31 +1439,11 @@
|
||||
{ label: '计划日期', value: plan.value?.planDate },
|
||||
{ label: '归属公司', value: getPlPlanCompanyLabel(plan.value?.belongsCompany) },
|
||||
{ label: '单据类型', value: getPlPlanTypeLabel(plan.value?.planType || '') },
|
||||
{ label: '跟进人', value: plan.value?.followUserName },
|
||||
{ label: '供方', value: plan.value?.supplierName },
|
||||
{ label: '需方', value: plan.value?.customerName }
|
||||
{ label: '跟进人', value: plan.value?.followUserName }
|
||||
])
|
||||
|
||||
const summaryCarrierName = computed(() => displayCarrierName.value)
|
||||
|
||||
const pickupViewFields = computed<ViewField[]>(() => [
|
||||
{ label: '取货地址', value: plan.value?.pickupAddress, span: 'full' },
|
||||
{ label: '取货时间', value: formatDate(plan.value?.pickupTime) || '—', long: false },
|
||||
{ label: '取货联系方式', value: plan.value?.pickupContact, long: false, fullSpan: false },
|
||||
{ label: '注意事项', value: plan.value?.pickupNotes, span: 'full' }
|
||||
])
|
||||
|
||||
const deliveryViewFields = computed<ViewField[]>(() => [
|
||||
{
|
||||
label: '送货地址',
|
||||
value: plan.value?.destinationAddress || plan.value?.destinationName,
|
||||
span: 'full'
|
||||
},
|
||||
{ label: '送货时间', value: formatDate(plan.value?.deliveryTime) || '—', long: false },
|
||||
{ label: '送货联系方式', value: plan.value?.deliveryContact, long: false, fullSpan: false },
|
||||
{ label: '注意事项', value: plan.value?.destinationNotes, span: 'full' }
|
||||
])
|
||||
|
||||
const freightViewFields = computed<ViewField[]>(() => {
|
||||
const hasFreight = plan.value?.hasFreight === 1
|
||||
const unit = freightUnitLabel.value
|
||||
@@ -1405,6 +1520,8 @@
|
||||
|
||||
<style scoped lang="scss">
|
||||
.pl-plan-view-tabs {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
min-height: 200px;
|
||||
|
||||
&.is-embedded {
|
||||
@@ -1412,22 +1529,88 @@
|
||||
margin-top: 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
&.is-hide-nav {
|
||||
.pl-plan-view-tabs__nav :deep(> .el-tabs__header) {
|
||||
display: none;
|
||||
}
|
||||
.pl-plan-view-body {
|
||||
flex: 1;
|
||||
min-height: 0;
|
||||
overflow-y: auto;
|
||||
padding-right: 4px;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 12px;
|
||||
}
|
||||
|
||||
.pl-plan-view-tabs__nav :deep(> .el-tabs__content) {
|
||||
padding-top: 0;
|
||||
}
|
||||
.pl-plan-transport-block {
|
||||
& + & {
|
||||
margin-top: 12px;
|
||||
}
|
||||
}
|
||||
|
||||
.pl-plan-view-tabs__nav :deep(.el-tabs__content) {
|
||||
max-height: min(52vh, 560px);
|
||||
overflow-y: auto;
|
||||
padding-right: 4px;
|
||||
.pl-plan-view-stop-block {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 12px;
|
||||
min-width: 0;
|
||||
}
|
||||
|
||||
.pl-plan-view-stop-meta {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(2, minmax(0, 1fr));
|
||||
gap: 10px 16px;
|
||||
}
|
||||
|
||||
.pl-plan-view-party-field__label {
|
||||
font-size: 13px;
|
||||
color: var(--mint-text-muted, #64748b);
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
.pl-plan-view-delivery-block {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 12px;
|
||||
min-width: 0;
|
||||
}
|
||||
|
||||
.pl-plan-view-delivery-tabs {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
gap: 4px;
|
||||
margin-bottom: 10px;
|
||||
}
|
||||
|
||||
.pl-plan-view-delivery-tabs .pl-plan-delivery-tab {
|
||||
border: 1px solid #d9e8e2;
|
||||
background: #fff;
|
||||
border-radius: 6px;
|
||||
padding: 5px 10px;
|
||||
font-size: 11px;
|
||||
font-weight: 600;
|
||||
cursor: pointer;
|
||||
color: #64748b;
|
||||
font-family: inherit;
|
||||
max-width: 100%;
|
||||
text-align: left;
|
||||
line-height: 1.35;
|
||||
|
||||
&.is-active {
|
||||
border-color: #7dd3fc;
|
||||
background: #f0f9ff;
|
||||
color: #0284c7;
|
||||
}
|
||||
}
|
||||
|
||||
.pl-plan-view-delivery-tabs .pl-plan-delivery-tab__qty {
|
||||
margin-left: 4px;
|
||||
font-weight: 400;
|
||||
color: #94a3b8;
|
||||
}
|
||||
|
||||
@media (max-width: 900px) {
|
||||
.pl-plan-view-stop-meta {
|
||||
grid-template-columns: 1fr;
|
||||
}
|
||||
}
|
||||
|
||||
.pl-plan-form-section {
|
||||
|
||||
@@ -68,7 +68,11 @@
|
||||
header-align="left"
|
||||
class-name="col-name-wrap"
|
||||
label-class-name="col-name-wrap"
|
||||
/>
|
||||
>
|
||||
<template #default="{ row }">
|
||||
<PlProductNameHazardCell :product="row" />
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column
|
||||
label="品牌"
|
||||
min-width="140"
|
||||
@@ -218,6 +222,7 @@
|
||||
import ListPagination from '@/components/ListPagination/index.vue'
|
||||
import ListQuickSearchInput from '@/components/business/list-quick-search-input/index.vue'
|
||||
import ProductFormDialog from '@/components/business/product-form-dialog/index.vue'
|
||||
import PlProductNameHazardCell from '@/components/business/pl-product-name-hazard-cell/index.vue'
|
||||
import {
|
||||
fetchCategoryTree,
|
||||
fetchProductList,
|
||||
@@ -238,6 +243,8 @@
|
||||
unit?: string
|
||||
taxRate?: number
|
||||
status?: string
|
||||
isToxic?: number
|
||||
isExplosive?: number
|
||||
brands?: ProductBrandItem[]
|
||||
aliases?: ProductAliasItem[]
|
||||
}
|
||||
|
||||
@@ -1,4 +1,6 @@
|
||||
import { computed, ref, watch, type Ref } from 'vue'
|
||||
import { useDictStore } from '@/store/modules/dict'
|
||||
import { getProductUnitLabel } from '@/utils/crm-product-display'
|
||||
|
||||
export interface FreightCalcProductRow {
|
||||
quantity?: number | null
|
||||
@@ -24,8 +26,8 @@ export function sumProductQuantities(products: FreightCalcProductRow[]) {
|
||||
export function resolveFreightUnitLabel(products: FreightCalcProductRow[]) {
|
||||
const units = products.map(row => row.unit).filter(Boolean) as string[]
|
||||
if (!units.length) return '吨'
|
||||
const first = units[0]
|
||||
return first
|
||||
const dictStore = useDictStore()
|
||||
return getProductUnitLabel(dictStore.getLabel.bind(dictStore), units[0])
|
||||
}
|
||||
|
||||
export function usePlFreightCalc(options: {
|
||||
|
||||
@@ -8,11 +8,10 @@ import type {
|
||||
import { planApi } from '@/api/pl'
|
||||
import DbPoundSlipQrcodeDialog from '@/components/business/db/DbPoundSlipQrcodeDialog.vue'
|
||||
import { useDictStore } from '@/store/modules/dict'
|
||||
import { formatDate } from '@/utils/format'
|
||||
import { appendAmapNavLine, buildAmapNavigationUrl } from '@/utils/amap/navigation'
|
||||
import { pickBxData } from '@/utils/http/bx'
|
||||
import { formatPlanProductListText } from '@/utils/pl-display'
|
||||
import { buildSiteSummaryFromInventoryLinks } from '@/utils/db-site-summary'
|
||||
import { buildDriverSummaryFromPlan, buildDriverStopBlocksFromPlan } from '@/utils/pl-driver-summary'
|
||||
import { buildSiteSummaryFromInventoryLinks, buildSiteStopBlocksFromPlan } from '@/utils/db-site-summary'
|
||||
|
||||
export function usePlPlanArrangeActions() {
|
||||
const dictStore = useDictStore()
|
||||
@@ -27,23 +26,26 @@ export function usePlPlanArrangeActions() {
|
||||
const selectedInventoryId = ref('')
|
||||
const selectedInventoryUnit = ref('')
|
||||
const qrcodeDialogRef = ref<InstanceType<typeof DbPoundSlipQrcodeDialog> | null>(null)
|
||||
const poundQrcodePickVisible = ref(false)
|
||||
const poundQrcodePickRecords = ref<TransportInventoryLink[]>([])
|
||||
|
||||
const showArrangeActions = computed(
|
||||
() =>
|
||||
Boolean(
|
||||
plan.value?.transportStatus === 'arranged' &&
|
||||
plan.value?.followStatus !== 'cancelled' &&
|
||||
(driverUrl.value || siteRecords.value.length || inventoryRecords.value.length)
|
||||
)
|
||||
const showArrangeActions = computed(() =>
|
||||
Boolean(
|
||||
plan.value?.transportStatus === 'arranged' &&
|
||||
plan.value?.followStatus !== 'cancelled' &&
|
||||
(driverUrl.value || siteRecords.value.length || inventoryRecords.value.length)
|
||||
)
|
||||
)
|
||||
|
||||
const hasSiteInventoryRecords = computed(() => siteRecords.value.length > 0)
|
||||
|
||||
const hasSiteLinks = computed(() => siteRecords.value.some(item => Boolean(item.siteUrl?.trim())))
|
||||
const hasSiteLinks = computed(() =>
|
||||
siteRecords.value.some((item) => Boolean(item.siteUrl?.trim()))
|
||||
)
|
||||
|
||||
/** 勾选「生成地磅单」后才会关联 db_purchase_plan,磅单二维码仅针对这类记录 */
|
||||
const dibangInventoryRecords = computed(() =>
|
||||
inventoryRecords.value.filter(item => Boolean(item.dbPurchasePlanId?.trim()))
|
||||
inventoryRecords.value.filter((item) => Boolean(item.dbPurchasePlanId?.trim()))
|
||||
)
|
||||
|
||||
const hasDibangInventoryRecords = computed(() => dibangInventoryRecords.value.length > 0)
|
||||
@@ -62,6 +64,8 @@ export function usePlPlanArrangeActions() {
|
||||
qrcodeVisible.value = false
|
||||
selectedInventoryId.value = ''
|
||||
selectedInventoryUnit.value = ''
|
||||
poundQrcodePickVisible.value = false
|
||||
poundQrcodePickRecords.value = []
|
||||
}
|
||||
|
||||
function applyArrangeResult(
|
||||
@@ -122,58 +126,19 @@ export function usePlPlanArrangeActions() {
|
||||
licensePlate?: string
|
||||
driverUrl?: string
|
||||
}) {
|
||||
const plate =
|
||||
options?.licensePlate || licensePlate.value || plan.value?.licensePlate || '—'
|
||||
const lines = [`【${plate} - 运输安排】`, `计划号:${plan.value?.planNo || '—'}`]
|
||||
lines.push(`车牌:${plate}`)
|
||||
lines.push(
|
||||
`时间:${formatDate(plan.value?.pickupTime) || plan.value?.planDate || '—'}`
|
||||
)
|
||||
const productText = products.value
|
||||
.map(p => formatPlanProductListText(p, getUnitLabel, { usePlannedQuantity: true }))
|
||||
.join(';')
|
||||
lines.push(`产品:${productText || '—'}`)
|
||||
|
||||
const pickupAddress =
|
||||
options?.pickupAddress || plan.value?.pickupAddress || options?.startPoint || '—'
|
||||
const destinationAddress =
|
||||
options?.destinationAddress ||
|
||||
plan.value?.destinationAddress ||
|
||||
plan.value?.destinationName ||
|
||||
options?.endPoint ||
|
||||
'—'
|
||||
lines.push(`取货地址:${pickupAddress}`)
|
||||
lines.push(`送货地址:${destinationAddress}`)
|
||||
|
||||
const pickupLng = options?.pickupLng ?? plan.value?.pickupLng
|
||||
const pickupLat = options?.pickupLat ?? plan.value?.pickupLat
|
||||
const destinationLng = options?.destinationLng ?? plan.value?.destinationLng
|
||||
const destinationLat = options?.destinationLat ?? plan.value?.destinationLat
|
||||
appendAmapNavLine(
|
||||
lines,
|
||||
'取货导航',
|
||||
buildAmapNavigationUrl(pickupLng, pickupLat, pickupAddress !== '—' ? pickupAddress : '取货点')
|
||||
)
|
||||
appendAmapNavLine(
|
||||
lines,
|
||||
'送货导航',
|
||||
buildAmapNavigationUrl(
|
||||
destinationLng,
|
||||
destinationLat,
|
||||
destinationAddress !== '—' ? destinationAddress : '送货点'
|
||||
)
|
||||
)
|
||||
|
||||
lines.push(
|
||||
`取货联系方式:${options?.pickupContact || plan.value?.pickupContact || '—'}`
|
||||
)
|
||||
lines.push(`取货注意事项:${options?.pickupNotes || plan.value?.pickupNotes || '—'}`)
|
||||
lines.push(
|
||||
`送货联系方式:${options?.deliveryContact || plan.value?.deliveryContact || '—'}`
|
||||
)
|
||||
lines.push(`送货注意事项:${options?.destinationNotes || plan.value?.destinationNotes || '—'}`)
|
||||
lines.push(`司机链接:${options?.driverUrl || driverUrl.value || '—'}`)
|
||||
return lines.join('\n')
|
||||
return buildDriverSummaryFromPlan({
|
||||
plan: plan.value || undefined,
|
||||
planNo: plan.value?.planNo,
|
||||
licensePlate: options?.licensePlate || licensePlate.value || plan.value?.licensePlate,
|
||||
pickupTime: plan.value?.pickupTime,
|
||||
planDate: plan.value?.planDate,
|
||||
personnelSummary: plan.value?.personnelSummary,
|
||||
driverUrl: options?.driverUrl || driverUrl.value,
|
||||
products: products.value,
|
||||
getUnitLabel,
|
||||
stopBlocks: buildDriverStopBlocksFromPlan(plan.value, getUnitLabel),
|
||||
...options
|
||||
})
|
||||
}
|
||||
|
||||
async function copyDriverUrl(url?: string) {
|
||||
@@ -184,7 +149,7 @@ export function usePlPlanArrangeActions() {
|
||||
}
|
||||
|
||||
function resolveSiteRecordProductText(record: TransportSiteLink) {
|
||||
const product = products.value.find(item => item.id === record.planProductId)
|
||||
const product = products.value.find((item) => item.id === record.planProductId)
|
||||
if (product) {
|
||||
return formatPlanProductListText(product, getUnitLabel, { usePlannedQuantity: true })
|
||||
}
|
||||
@@ -197,10 +162,11 @@ export function usePlPlanArrangeActions() {
|
||||
licensePlate: options?.licensePlate || licensePlate.value || plan.value?.licensePlate,
|
||||
pickupTime: plan.value?.pickupTime,
|
||||
planDate: plan.value?.planDate,
|
||||
records: siteRecords.value.map(record => ({
|
||||
records: siteRecords.value.map((record) => ({
|
||||
...record,
|
||||
productText: resolveSiteRecordProductText(record)
|
||||
}))
|
||||
})),
|
||||
stopBlocks: buildSiteStopBlocksFromPlan(plan.value)
|
||||
})
|
||||
}
|
||||
|
||||
@@ -234,11 +200,25 @@ export function usePlPlanArrangeActions() {
|
||||
}
|
||||
|
||||
function resolveInventoryUnitLabel(record: TransportInventoryLink) {
|
||||
const product = products.value.find(item => item.id === record.planProductId)
|
||||
const product = products.value.find((item) => item.id === record.planProductId)
|
||||
const unitRaw = product?.unit || ''
|
||||
return unitRaw ? getUnitLabel(unitRaw) : '吨'
|
||||
}
|
||||
|
||||
async function copyPoundSlipQrcodeForRecord(
|
||||
record: TransportInventoryLink,
|
||||
options?: { preview?: boolean }
|
||||
) {
|
||||
selectedInventoryId.value = record.dbInventoryId
|
||||
selectedInventoryUnit.value = resolveInventoryUnitLabel(record)
|
||||
qrcodeVisible.value = true
|
||||
await nextTick()
|
||||
if (options?.preview) {
|
||||
return
|
||||
}
|
||||
await qrcodeDialogRef.value?.copyQrcodeImage()
|
||||
}
|
||||
|
||||
async function copyPoundSlipQrcode() {
|
||||
const records = dibangInventoryRecords.value
|
||||
if (!records.length) {
|
||||
@@ -246,36 +226,19 @@ export function usePlPlanArrangeActions() {
|
||||
return
|
||||
}
|
||||
if (records.length === 1) {
|
||||
selectedInventoryId.value = records[0].dbInventoryId
|
||||
selectedInventoryUnit.value = resolveInventoryUnitLabel(records[0])
|
||||
qrcodeVisible.value = true
|
||||
await nextTick()
|
||||
await qrcodeDialogRef.value?.copyQrcodeImage()
|
||||
await copyPoundSlipQrcodeForRecord(records[0])
|
||||
return
|
||||
}
|
||||
poundQrcodePickRecords.value = records
|
||||
poundQrcodePickVisible.value = true
|
||||
}
|
||||
|
||||
try {
|
||||
const { value } = await ElMessageBox.prompt('请选择要复制二维码的产品行', '复制磅单二维码', {
|
||||
inputPlaceholder: records.map((item, idx) => `${idx + 1}. ${item.productName}`).join('\n'),
|
||||
confirmButtonText: '确定',
|
||||
inputValidator: val => {
|
||||
const index = Number(val) - 1
|
||||
if (!Number.isInteger(index) || index < 0 || index >= records.length) {
|
||||
return '请输入有效序号'
|
||||
}
|
||||
return true
|
||||
}
|
||||
})
|
||||
const index = Number(value) - 1
|
||||
const record = records[index]
|
||||
selectedInventoryId.value = record.dbInventoryId
|
||||
selectedInventoryUnit.value = resolveInventoryUnitLabel(record)
|
||||
qrcodeVisible.value = true
|
||||
await nextTick()
|
||||
await qrcodeDialogRef.value?.copyQrcodeImage()
|
||||
} catch {
|
||||
// 用户取消
|
||||
}
|
||||
async function handlePoundQrcodePickCopy(record: TransportInventoryLink) {
|
||||
await copyPoundSlipQrcodeForRecord(record)
|
||||
}
|
||||
|
||||
async function handlePoundQrcodePickPreview(record: TransportInventoryLink) {
|
||||
await copyPoundSlipQrcodeForRecord(record, { preview: true })
|
||||
}
|
||||
|
||||
return {
|
||||
@@ -289,6 +252,8 @@ export function usePlPlanArrangeActions() {
|
||||
selectedInventoryId,
|
||||
selectedInventoryUnit,
|
||||
qrcodeDialogRef,
|
||||
poundQrcodePickVisible,
|
||||
poundQrcodePickRecords,
|
||||
showArrangeActions,
|
||||
hasSiteInventoryRecords,
|
||||
hasSiteLinks,
|
||||
@@ -302,6 +267,9 @@ export function usePlPlanArrangeActions() {
|
||||
copyDriverUrl,
|
||||
copySiteSummary,
|
||||
copyPlanSummary,
|
||||
copyPoundSlipQrcode
|
||||
copyPoundSlipQrcode,
|
||||
copyPoundSlipQrcodeForRecord,
|
||||
handlePoundQrcodePickCopy,
|
||||
handlePoundQrcodePickPreview
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,211 @@
|
||||
import type { ComputedRef, Ref } from 'vue'
|
||||
import {
|
||||
planApi,
|
||||
transportApi,
|
||||
type Plan,
|
||||
type PlanProduct,
|
||||
type TransportArrange,
|
||||
type TransportArrangeResult
|
||||
} from '@/api/pl'
|
||||
import { pickBxData } from '@/utils/http/bx'
|
||||
import { planRequiresSiteLink } from '@/utils/pl-internal-customer'
|
||||
import type { PlanDeliveryForm, PlanLoadForm } from '@/utils/pl-plan-stop-form'
|
||||
|
||||
export interface ArrangeHistoricalFlags {
|
||||
hasHistoricalDibang: boolean
|
||||
hasHistoricalSiteLinks: boolean
|
||||
}
|
||||
|
||||
export async function loadArrangeHistoricalFlags(planId: string): Promise<ArrangeHistoricalFlags> {
|
||||
try {
|
||||
const infoRes = await planApi.getArrangeInfo(planId)
|
||||
const info = pickBxData<{
|
||||
inventoryRecords?: unknown[]
|
||||
siteRecords?: unknown[]
|
||||
}>(infoRes)
|
||||
return {
|
||||
hasHistoricalDibang: (info?.inventoryRecords?.length || 0) > 0,
|
||||
hasHistoricalSiteLinks: (info?.siteRecords?.length || 0) > 0
|
||||
}
|
||||
} catch {
|
||||
return { hasHistoricalDibang: false, hasHistoricalSiteLinks: false }
|
||||
}
|
||||
}
|
||||
|
||||
function buildTransportMediumText(
|
||||
products: PlanProduct[],
|
||||
getUnitLabel: (unit: string) => string
|
||||
) {
|
||||
return products
|
||||
.map((product) => {
|
||||
const name = product.productName?.trim()
|
||||
if (!name) return ''
|
||||
const model = (product.model || product.packageSpec || '').trim()
|
||||
const qty = product.quantity ?? product.inboundEstimateQty ?? product.outboundEstimateQty ?? ''
|
||||
const unit = getUnitLabel(product.unit || '吨')
|
||||
const detail = [model, qty, unit].filter((part) => part !== '' && part != null).join('、')
|
||||
return detail ? `${name}(${detail})` : name
|
||||
})
|
||||
.filter(Boolean)
|
||||
.join(';')
|
||||
}
|
||||
|
||||
function buildStopDibangOptions(
|
||||
plan: Plan,
|
||||
loadForm: PlanLoadForm,
|
||||
deliveryForms: PlanDeliveryForm[]
|
||||
) {
|
||||
const options: TransportArrange['stopDibangOptions'] = []
|
||||
if (plan.load?.id) {
|
||||
options.push({
|
||||
stopType: 'load',
|
||||
stopId: plan.load.id,
|
||||
generateDibang: loadForm.generateDibang === 1
|
||||
})
|
||||
}
|
||||
const deliveries = [...(plan.deliveries || [])].sort((a, b) => (a.seq ?? 0) - (b.seq ?? 0))
|
||||
deliveries.forEach((delivery, index) => {
|
||||
if (!delivery.id) return
|
||||
const form =
|
||||
deliveryForms.find((row) => row.id === delivery.id) ||
|
||||
deliveryForms.find((row) => row.seq === delivery.seq) ||
|
||||
deliveryForms[index]
|
||||
options.push({
|
||||
stopType: 'delivery',
|
||||
stopId: delivery.id,
|
||||
generateDibang: form?.generateDibang === 1
|
||||
})
|
||||
})
|
||||
return options
|
||||
}
|
||||
|
||||
export function planHasAnyDibangSelected(
|
||||
plan: Plan,
|
||||
loadForm: PlanLoadForm,
|
||||
deliveryForms: PlanDeliveryForm[]
|
||||
) {
|
||||
const stopOptions = buildStopDibangOptions(plan, loadForm, deliveryForms)
|
||||
if (stopOptions.length > 0) {
|
||||
return stopOptions.some((row) => row.generateDibang)
|
||||
}
|
||||
return loadForm.generateDibang === 1 || deliveryForms.some((row) => row.generateDibang === 1)
|
||||
}
|
||||
|
||||
export interface BuildArrangePayloadInput {
|
||||
plan: Plan
|
||||
vehicleId: string
|
||||
driverId: string
|
||||
carrierId: string
|
||||
loadForm: PlanLoadForm
|
||||
deliveryForms: PlanDeliveryForm[]
|
||||
products: PlanProduct[]
|
||||
remark: string
|
||||
distanceKm: number | null
|
||||
freightType: string
|
||||
hasFreight: number
|
||||
freightCalc: {
|
||||
freightPrice: Ref<number | null>
|
||||
calculatedFreight: ComputedRef<number>
|
||||
freightAmount: Ref<number | null>
|
||||
}
|
||||
getUnitLabel: (unit: string) => string
|
||||
}
|
||||
|
||||
export function buildArrangePayloadFromPlanForm(input: BuildArrangePayloadInput): TransportArrange {
|
||||
const firstDelivery = input.deliveryForms[0]
|
||||
const useMultiStopDibang = Boolean(input.plan.load?.id && (input.plan.deliveries?.length || 0) > 0)
|
||||
const stopDibangOptions = useMultiStopDibang
|
||||
? buildStopDibangOptions(input.plan, input.loadForm, input.deliveryForms)
|
||||
: undefined
|
||||
const generateDibangPlan = !useMultiStopDibang
|
||||
? input.loadForm.generateDibang === 1 || Boolean(firstDelivery?.generateDibang === 1)
|
||||
: undefined
|
||||
|
||||
return {
|
||||
vehicleId: input.vehicleId,
|
||||
driverId: input.driverId || undefined,
|
||||
carrierId: input.carrierId || undefined,
|
||||
pickupAddress: input.loadForm.address || undefined,
|
||||
pickupLng: input.loadForm.lng,
|
||||
pickupLat: input.loadForm.lat,
|
||||
pickupTime: input.loadForm.loadTime || undefined,
|
||||
pickupContact: input.loadForm.contact || undefined,
|
||||
pickupNotes: input.loadForm.notes || undefined,
|
||||
destinationAddress: firstDelivery?.address || undefined,
|
||||
destinationLng: firstDelivery?.lng,
|
||||
destinationLat: firstDelivery?.lat,
|
||||
deliveryTime: firstDelivery?.deliveryTime || undefined,
|
||||
deliveryContact: firstDelivery?.contact || undefined,
|
||||
destinationNotes: firstDelivery?.notes || undefined,
|
||||
transportMedium: buildTransportMediumText(input.products, input.getUnitLabel) || undefined,
|
||||
distanceKm: input.distanceKm ?? undefined,
|
||||
freightType: input.freightType,
|
||||
freightPrice:
|
||||
input.freightType === 'by_weight'
|
||||
? (input.freightCalc.freightPrice.value ?? undefined)
|
||||
: undefined,
|
||||
freightAmount:
|
||||
input.hasFreight === 1
|
||||
? input.freightCalc.calculatedFreight.value ||
|
||||
input.freightCalc.freightAmount.value ||
|
||||
undefined
|
||||
: undefined,
|
||||
remark: input.remark || undefined,
|
||||
generateDibangPlan: useMultiStopDibang ? undefined : generateDibangPlan,
|
||||
stopDibangOptions: useMultiStopDibang && stopDibangOptions?.length ? stopDibangOptions : undefined
|
||||
}
|
||||
}
|
||||
|
||||
export async function confirmBeforePlanArrange(options: {
|
||||
isRearrange: boolean
|
||||
plan: Plan
|
||||
hasHistoricalDibang: boolean
|
||||
hasHistoricalSiteLinks: boolean
|
||||
hasAnyDibangSelected: boolean
|
||||
}) {
|
||||
const planSupportsSiteInventory = planRequiresSiteLink(options.plan)
|
||||
|
||||
if (options.isRearrange) {
|
||||
let confirmMessage = '司机链接将更新,旧链接将失效。是否继续?'
|
||||
if (options.hasHistoricalDibang) {
|
||||
confirmMessage = options.hasAnyDibangSelected
|
||||
? '将作废此前自动生成的地磅出入库单,并按当前勾选段重新进行地磅单生成。司机链接将更新,旧链接将失效。已执行或已关联磅单的单据不会被自动作废。是否继续?'
|
||||
: '将作废此前自动生成的地磅出入库单,且不会重新生成地磅联动单据。司机链接将更新,旧链接将失效。已执行或已关联磅单的单据不会被自动作废。是否继续?'
|
||||
} else if (options.hasHistoricalSiteLinks && planSupportsSiteInventory) {
|
||||
confirmMessage = '司机与现场链接将更新,旧链接将失效。是否继续?'
|
||||
} else if (options.hasAnyDibangSelected && planSupportsSiteInventory) {
|
||||
confirmMessage =
|
||||
'将按当前勾选段进行地磅单生成。司机链接将更新,旧链接将失效。是否继续?'
|
||||
}
|
||||
await ElMessageBox.confirm(confirmMessage, '调整运输确认', {
|
||||
type: 'warning',
|
||||
confirmButtonText: '继续调整',
|
||||
cancelButtonText: '取消'
|
||||
})
|
||||
return
|
||||
}
|
||||
|
||||
if (options.hasAnyDibangSelected && options.plan.transportId) {
|
||||
await ElMessageBox.confirm(
|
||||
'将作废本运输单此前待处理的出入库单,并按当前计划产品重新生成。已执行或已关联磅单的单据不会被自动作废。是否继续?',
|
||||
'地磅联动确认',
|
||||
{
|
||||
type: 'warning',
|
||||
confirmButtonText: '继续安排',
|
||||
cancelButtonText: '取消'
|
||||
}
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
export async function submitPlanArrange(
|
||||
planId: string,
|
||||
payload: TransportArrange
|
||||
): Promise<TransportArrangeResult> {
|
||||
const res = await transportApi.arrange(planId, payload)
|
||||
const result = pickBxData<TransportArrangeResult>(res)
|
||||
if (!result) {
|
||||
throw new Error('安排失败:未返回结果')
|
||||
}
|
||||
return result
|
||||
}
|
||||
@@ -0,0 +1,65 @@
|
||||
import { computed, unref, type ComputedRef, type Ref } from 'vue'
|
||||
import type { Plan } from '@/api/pl'
|
||||
import {
|
||||
buildPlPlanListSpanMethod,
|
||||
flattenPlanListRows,
|
||||
getPlanListDisplayIndex,
|
||||
type PlPlanListDisplayRow
|
||||
} from '@/utils/pl-plan-list-display-rows'
|
||||
|
||||
export function usePlPlanMergeListTable(options: {
|
||||
planList: Ref<Plan[]> | ComputedRef<Plan[]>
|
||||
visiblePlanMergeProps: ComputedRef<string[]>
|
||||
selectedRows: Ref<Plan[]>
|
||||
pagination: { page: number; pageSize: number }
|
||||
onView?: (plan: Plan) => void
|
||||
}) {
|
||||
const displayRows = computed(() => flattenPlanListRows(unref(options.planList)))
|
||||
|
||||
const planListSpanMethod = computed(() =>
|
||||
buildPlPlanListSpanMethod([...options.visiblePlanMergeProps.value])
|
||||
)
|
||||
|
||||
function getDisplayRowIndex(index: number) {
|
||||
return getPlanListDisplayIndex(
|
||||
displayRows.value,
|
||||
index,
|
||||
options.pagination.page,
|
||||
options.pagination.pageSize
|
||||
)
|
||||
}
|
||||
|
||||
function isPlanFirstRowSelectable(row: PlPlanListDisplayRow) {
|
||||
return row.isPlanFirstRow
|
||||
}
|
||||
|
||||
function handleDisplaySelectionChange(selection: PlPlanListDisplayRow[]) {
|
||||
const seen = new Set<string>()
|
||||
const plans: Plan[] = []
|
||||
for (const item of selection || []) {
|
||||
const plan = item?.plan
|
||||
if (!plan?.id || seen.has(plan.id)) continue
|
||||
seen.add(plan.id)
|
||||
plans.push(plan)
|
||||
}
|
||||
options.selectedRows.value = plans
|
||||
}
|
||||
|
||||
function handleDisplayRowDblClick(row: PlPlanListDisplayRow) {
|
||||
if (row?.plan && options.onView) options.onView(row.plan)
|
||||
}
|
||||
|
||||
function findPlanFirstDisplayRow(planId: string) {
|
||||
return displayRows.value.find((item) => item.plan.id === planId && item.isPlanFirstRow)
|
||||
}
|
||||
|
||||
return {
|
||||
displayRows,
|
||||
planListSpanMethod,
|
||||
getDisplayRowIndex,
|
||||
isPlanFirstRowSelectable,
|
||||
handleDisplaySelectionChange,
|
||||
handleDisplayRowDblClick,
|
||||
findPlanFirstDisplayRow
|
||||
}
|
||||
}
|
||||
@@ -57,6 +57,18 @@ export const staticRoutes: AppRouteRecordRaw[] = [
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
path: '/public/pl/transport-site/:token/history',
|
||||
name: 'PublicPlTransportMultiStopSiteHistory',
|
||||
component: () => import('@views/public/pl/transport-site/history.vue'),
|
||||
meta: { title: '现场记录', isHideTab: true, isPublicMobile: true }
|
||||
},
|
||||
{
|
||||
path: '/public/pl/transport-site/:token',
|
||||
name: 'PublicPlTransportMultiStopSite',
|
||||
component: () => import('@views/public/pl/transport-site/index.vue'),
|
||||
meta: { title: '现场回传', isHideTab: true, isPublicMobile: true }
|
||||
},
|
||||
{
|
||||
path: '/public/pl/transport/:token/history',
|
||||
name: 'PublicPlTransportHistory',
|
||||
|
||||
@@ -48,6 +48,45 @@
|
||||
}
|
||||
}
|
||||
|
||||
.public-pl-transport-page .stop-segment-title {
|
||||
display: inline-flex;
|
||||
flex-wrap: wrap;
|
||||
align-items: center;
|
||||
gap: 2px;
|
||||
min-width: 0;
|
||||
line-height: 1.35;
|
||||
}
|
||||
|
||||
.public-pl-transport-page .stop-segment-title__type {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
flex-shrink: 0;
|
||||
padding: 2px 8px;
|
||||
border-radius: 999px;
|
||||
background: #059669;
|
||||
color: #fff;
|
||||
font-size: 13px;
|
||||
font-weight: 700;
|
||||
line-height: 1.3;
|
||||
}
|
||||
|
||||
.public-pl-transport-page .stop-segment-title__sep {
|
||||
color: #94a3b8;
|
||||
font-weight: 500;
|
||||
}
|
||||
|
||||
.public-pl-transport-page .stop-segment-title__customer {
|
||||
color: #0f172a;
|
||||
font-size: 13px;
|
||||
font-weight: 600;
|
||||
}
|
||||
|
||||
.public-pl-transport-page .stop-segment-title__biz {
|
||||
color: #64748b;
|
||||
font-size: 12px;
|
||||
font-weight: 500;
|
||||
}
|
||||
|
||||
.public-pl-transport-page .section-card .van-cell {
|
||||
padding: 7px 14px;
|
||||
line-height: 1.35;
|
||||
|
||||
@@ -35,6 +35,19 @@ export function buildAmapSearchUrl(keyword?: string | null): string | null {
|
||||
return `https://www.amap.com/search?query=${encodeURIComponent(text)}`
|
||||
}
|
||||
|
||||
/** 优先坐标导航,无完整坐标时按地址关键词搜索兜底 */
|
||||
export function buildAmapNavigationUrlWithFallback(options: {
|
||||
lng?: number | null
|
||||
lat?: number | null
|
||||
name?: string
|
||||
address?: string
|
||||
}): string | null {
|
||||
const label = (options.name || options.address || '').trim() || '目的地'
|
||||
const nav = buildAmapNavigationUrl(options.lng, options.lat, label)
|
||||
if (nav) return nav
|
||||
return buildAmapSearchUrl(options.address || options.name || label)
|
||||
}
|
||||
|
||||
/** 优先坐标标记,否则按地址搜索 */
|
||||
export function buildAmapLocationUrl(options: {
|
||||
lng?: number | null
|
||||
|
||||
@@ -1,27 +1,138 @@
|
||||
import type { InventoryRecord } from '@/api/db/inventory'
|
||||
import type { TransportInventoryLink } from '@/api/pl'
|
||||
import type { PlanDelivery, PlanLoad, PlanStopProduct } from '@/api/pl'
|
||||
import { formatDate } from '@/utils/format'
|
||||
import { isPlInternalCustomerName } from '@/utils/pl-internal-customer'
|
||||
|
||||
const SITE_INSTRUCTION = '说明:请打开链接上传现场附件并填写备注。'
|
||||
|
||||
type SiteSummaryRecord = {
|
||||
export type SiteSummaryStopBlock = {
|
||||
label: string
|
||||
customerName?: string
|
||||
businessType?: string
|
||||
address?: string
|
||||
productLines: string[]
|
||||
}
|
||||
|
||||
export type SiteSummaryRecord = {
|
||||
productName?: string
|
||||
productText?: string
|
||||
batchNo?: string
|
||||
planNo?: string
|
||||
siteUrl?: string
|
||||
businessType?: string
|
||||
siteFeedbackRemark?: string
|
||||
siteFeedbackTime?: string
|
||||
}
|
||||
|
||||
function formatSiteSummaryProductLine(record: SiteSummaryRecord) {
|
||||
return record.productText || record.productName || '—'
|
||||
}
|
||||
|
||||
function isSegmentSiteRecord(record: SiteSummaryRecord) {
|
||||
return (record.businessType || '').includes('按段')
|
||||
}
|
||||
|
||||
function formatStopProductLine(product: PlanStopProduct) {
|
||||
const name = (product.productName || '').trim() || '—'
|
||||
const qty = product.planQty
|
||||
const unit = (product.unit || '吨').trim()
|
||||
if (qty == null) return name
|
||||
return `${name} ${qty}${unit}`
|
||||
}
|
||||
|
||||
function isSiteVisibleStop(customerName?: string | null, generateDibang?: number | null) {
|
||||
return isPlInternalCustomerName(customerName) && Number(generateDibang || 0) === 1
|
||||
}
|
||||
|
||||
export function buildSiteStopBlocksFromPlan(
|
||||
plan?: {
|
||||
load?: PlanLoad | null
|
||||
deliveries?: PlanDelivery[] | null
|
||||
} | null
|
||||
): SiteSummaryStopBlock[] {
|
||||
if (!plan) return []
|
||||
const blocks: SiteSummaryStopBlock[] = []
|
||||
const load = plan.load
|
||||
if (load && isSiteVisibleStop(load.customerName, load.generateDibang)) {
|
||||
blocks.push({
|
||||
label: '装货',
|
||||
customerName: load.customerName || undefined,
|
||||
businessType: load.dibangDirection || undefined,
|
||||
address: load.address || undefined,
|
||||
productLines: (load.products || []).map(formatStopProductLine).filter(Boolean)
|
||||
})
|
||||
}
|
||||
for (const delivery of plan.deliveries || []) {
|
||||
if (!isSiteVisibleStop(delivery.customerName, delivery.generateDibang)) continue
|
||||
const seq = delivery.seq != null ? Number(delivery.seq) : 0
|
||||
blocks.push({
|
||||
label: seq > 0 ? `送货 #${seq}` : '送货',
|
||||
customerName: delivery.customerName || undefined,
|
||||
businessType: delivery.dibangDirection || undefined,
|
||||
address: delivery.address || undefined,
|
||||
productLines: (delivery.products || []).map(formatStopProductLine).filter(Boolean)
|
||||
})
|
||||
}
|
||||
return blocks
|
||||
}
|
||||
|
||||
function appendSiteRecordCardLines(
|
||||
lines: string[],
|
||||
record: SiteSummaryRecord,
|
||||
options: { showHeadline?: boolean }
|
||||
) {
|
||||
const headline = (record.productName || '').trim()
|
||||
const productText = formatSiteSummaryProductLine(record)
|
||||
if (options.showHeadline && headline) {
|
||||
lines.push(headline)
|
||||
}
|
||||
if (record.businessType && record.businessType !== '—') {
|
||||
lines.push(`业务类型:${record.businessType}`)
|
||||
}
|
||||
if (record.siteFeedbackTime && record.siteFeedbackTime !== '—') {
|
||||
lines.push(`保存时间:${record.siteFeedbackTime}`)
|
||||
}
|
||||
if (record.batchNo) {
|
||||
lines.push(`出入库单号:${record.batchNo}`)
|
||||
}
|
||||
if (productText && productText !== '—' && productText !== headline) {
|
||||
lines.push(`产品:${productText}`)
|
||||
}
|
||||
if (record.siteFeedbackRemark && record.siteFeedbackRemark !== '—') {
|
||||
lines.push(`现场备注:${record.siteFeedbackRemark}`)
|
||||
}
|
||||
lines.push(`现场链接:${record.siteUrl}`)
|
||||
}
|
||||
|
||||
function formatSiteDibangDirectionLabel(direction?: string | null) {
|
||||
const value = (direction || '').trim()
|
||||
if (!value || value === 'none') return ''
|
||||
if (value === 'outbound') return '出库'
|
||||
if (value === 'inbound') return '入库'
|
||||
return value
|
||||
}
|
||||
|
||||
function appendStopBlockLines(lines: string[], stop: SiteSummaryStopBlock) {
|
||||
const bizLabel = formatSiteDibangDirectionLabel(stop.businessType)
|
||||
const biz = bizLabel ? `(${bizLabel})` : ''
|
||||
lines.push(`【${stop.label} · ${stop.customerName || '—'}】${biz}`)
|
||||
if (stop.address) {
|
||||
lines.push(`地址:${stop.address}`)
|
||||
}
|
||||
if (stop.productLines.length) {
|
||||
stop.productLines.forEach((line) => lines.push(`产品:${line}`))
|
||||
} else {
|
||||
lines.push('产品:—')
|
||||
}
|
||||
}
|
||||
|
||||
export function buildSiteSummaryFromInventoryLinks(options: {
|
||||
planNo?: string
|
||||
licensePlate?: string
|
||||
pickupTime?: string
|
||||
planDate?: string
|
||||
records: SiteSummaryRecord[]
|
||||
stopBlocks?: SiteSummaryStopBlock[]
|
||||
}) {
|
||||
const lines = ['【运输现场】']
|
||||
const planNo = options.planNo || options.records[0]?.planNo
|
||||
@@ -30,23 +141,33 @@ export function buildSiteSummaryFromInventoryLinks(options: {
|
||||
const time = formatDate(options.pickupTime) || options.planDate
|
||||
if (time) lines.push(`时间:${time}`)
|
||||
|
||||
const validRecords = options.records.filter(item => item.siteUrl)
|
||||
const validRecords = options.records.filter((item) => item.siteUrl)
|
||||
if (!validRecords.length) {
|
||||
lines.push('现场链接:—')
|
||||
return lines.join('\n')
|
||||
}
|
||||
|
||||
if (validRecords.length === 1) {
|
||||
const stopBlocks = options.stopBlocks || []
|
||||
const useSegmentLayout =
|
||||
stopBlocks.length > 0 && validRecords.some((record) => isSegmentSiteRecord(record))
|
||||
|
||||
if (useSegmentLayout) {
|
||||
lines.push('')
|
||||
stopBlocks.forEach((stop, index) => {
|
||||
if (index > 0) lines.push('')
|
||||
appendStopBlockLines(lines, stop)
|
||||
})
|
||||
lines.push('')
|
||||
const record = validRecords[0]
|
||||
lines.push(`产品:${formatSiteSummaryProductLine(record)}`)
|
||||
if (record.batchNo) lines.push(`出入库单号:${record.batchNo}`)
|
||||
lines.push(`现场链接:${record.siteUrl}`)
|
||||
} else if (validRecords.length === 1) {
|
||||
lines.push('')
|
||||
appendSiteRecordCardLines(lines, validRecords[0], { showHeadline: true })
|
||||
} else {
|
||||
lines.push('')
|
||||
validRecords.forEach((record, index) => {
|
||||
lines.push(`【${index + 1}】${formatSiteSummaryProductLine(record)}`)
|
||||
if (record.batchNo) lines.push(`出入库单号:${record.batchNo}`)
|
||||
lines.push(`现场链接:${record.siteUrl}`)
|
||||
appendSiteRecordCardLines(lines, record, { showHeadline: false })
|
||||
if (index < validRecords.length - 1) lines.push('')
|
||||
})
|
||||
}
|
||||
|
||||
@@ -0,0 +1,149 @@
|
||||
/** 送(提)货单:按送货客户聚合(一车多卸) */
|
||||
import type { Plan, PlanDelivery, PlanProduct, PlanStopProduct } from '@/api/pl'
|
||||
|
||||
export interface DeliveryPrintCustomerOption {
|
||||
customerId: string
|
||||
customerName: string
|
||||
deliveryCount: number
|
||||
}
|
||||
|
||||
function customerKey(customerId?: string | null, customerName?: string | null) {
|
||||
const id = String(customerId || '').trim()
|
||||
if (id) return `id:${id}`
|
||||
const name = String(customerName || '').trim()
|
||||
if (name) return `name:${name}`
|
||||
return ''
|
||||
}
|
||||
|
||||
function resolveCustomerId(customerId?: string | null, customerName?: string | null) {
|
||||
const id = String(customerId || '').trim()
|
||||
if (id) return id
|
||||
return String(customerName || '').trim()
|
||||
}
|
||||
|
||||
function deliveryMatchesCustomer(delivery: PlanDelivery, customerId: string) {
|
||||
const target = String(customerId || '').trim()
|
||||
if (!target) return false
|
||||
const id = String(delivery.customerId || '').trim()
|
||||
if (id && id === target) return true
|
||||
const name = String(delivery.customerName || '').trim()
|
||||
return !id && name === target
|
||||
}
|
||||
|
||||
/** 从计划送货段统计去重客户(仅 1 个时可跳过选客户弹窗) */
|
||||
export function listDeliveryPrintCustomers(plan?: Pick<Plan, 'deliveries'> | null): DeliveryPrintCustomerOption[] {
|
||||
const deliveries = plan?.deliveries || []
|
||||
const grouped = new Map<string, DeliveryPrintCustomerOption & { minSeq: number }>()
|
||||
for (const delivery of deliveries) {
|
||||
const key = customerKey(delivery.customerId, delivery.customerName)
|
||||
if (!key) continue
|
||||
const existing = grouped.get(key)
|
||||
if (!existing) {
|
||||
grouped.set(key, {
|
||||
customerId: resolveCustomerId(delivery.customerId, delivery.customerName),
|
||||
customerName: String(delivery.customerName || '').trim() || '—',
|
||||
deliveryCount: 1,
|
||||
minSeq: delivery.seq ?? 9999
|
||||
})
|
||||
continue
|
||||
}
|
||||
existing.deliveryCount += 1
|
||||
existing.minSeq = Math.min(existing.minSeq, delivery.seq ?? 9999)
|
||||
}
|
||||
return [...grouped.values()]
|
||||
.sort((a, b) => a.minSeq - b.minSeq || a.customerName.localeCompare(b.customerName, 'zh-CN'))
|
||||
.map(({ customerId, customerName, deliveryCount }) => ({
|
||||
customerId,
|
||||
customerName,
|
||||
deliveryCount
|
||||
}))
|
||||
}
|
||||
|
||||
function stopProductToPlanProduct(product: PlanStopProduct, planId: string): PlanProduct {
|
||||
return {
|
||||
id: product.id || product.planProductId || product.productId,
|
||||
planId,
|
||||
productId: product.productId,
|
||||
productNo: product.productNo,
|
||||
productName: product.productName,
|
||||
model: product.model,
|
||||
unit: product.unit,
|
||||
packageSpec: product.packageSpec,
|
||||
deliveryMethod: product.deliveryMethod,
|
||||
quantity: product.planQty,
|
||||
outboundEstimateQty: product.planQty,
|
||||
outboundQty: product.outboundQty,
|
||||
outboundPrice: product.outboundPrice,
|
||||
outboundAmount: product.outboundAmount,
|
||||
inboundQty: product.inboundQty,
|
||||
inboundPrice: product.inboundPrice,
|
||||
inboundAmount: product.inboundAmount,
|
||||
isExplosive: 0,
|
||||
isToxic: 0,
|
||||
remark: product.remark
|
||||
}
|
||||
}
|
||||
|
||||
function mergePlanProducts(products: PlanProduct[]): PlanProduct[] {
|
||||
const merged = new Map<string, PlanProduct>()
|
||||
const order: string[] = []
|
||||
for (const product of products) {
|
||||
const key = String(product.productId || '').trim() || product.id
|
||||
const existing = merged.get(key)
|
||||
if (!existing) {
|
||||
merged.set(key, { ...product })
|
||||
order.push(key)
|
||||
continue
|
||||
}
|
||||
const sum = (a?: number | null, b?: number | null) => {
|
||||
if (a == null && b == null) return undefined
|
||||
return Number(a || 0) + Number(b || 0)
|
||||
}
|
||||
existing.quantity = sum(existing.quantity, product.quantity)
|
||||
existing.outboundEstimateQty = sum(existing.outboundEstimateQty, product.outboundEstimateQty)
|
||||
existing.outboundQty = sum(existing.outboundQty, product.outboundQty)
|
||||
existing.inboundQty = sum(existing.inboundQty, product.inboundQty)
|
||||
if (!String(existing.remark || '').trim() && String(product.remark || '').trim()) {
|
||||
existing.remark = product.remark
|
||||
}
|
||||
}
|
||||
return order.map((key) => merged.get(key)!)
|
||||
}
|
||||
|
||||
/**
|
||||
* 按送货客户生成送(提)货单打印视图:
|
||||
* - 收货单位 = 客户名
|
||||
* - 联系方式/地址取 seq 最小送货段
|
||||
* - 同客户多段产品行合并
|
||||
*/
|
||||
export function applyDeliveryCustomerToPlan(plan: Plan, customerId: string): Plan {
|
||||
const deliveries = [...(plan.deliveries || [])]
|
||||
.filter((item) => deliveryMatchesCustomer(item, customerId))
|
||||
.sort((a, b) => (a.seq ?? 9999) - (b.seq ?? 9999))
|
||||
if (!deliveries.length) {
|
||||
throw new Error('未找到匹配的送货客户')
|
||||
}
|
||||
const primary = deliveries[0]
|
||||
const products = mergePlanProducts(
|
||||
deliveries.flatMap((delivery) =>
|
||||
(delivery.products || []).map((product) => stopProductToPlanProduct(product, plan.id))
|
||||
)
|
||||
)
|
||||
return {
|
||||
...plan,
|
||||
customerId: resolveCustomerId(primary.customerId, primary.customerName),
|
||||
customerName: String(primary.customerName || '').trim(),
|
||||
destinationName: String(primary.customerName || '').trim(),
|
||||
destinationAddress: String(primary.address || '').trim() || plan.destinationAddress,
|
||||
deliveryContact: String(primary.contact || '').trim() || plan.deliveryContact,
|
||||
destinationNotes: String(primary.notes || '').trim() || plan.destinationNotes,
|
||||
products: products.length ? products : plan.products
|
||||
}
|
||||
}
|
||||
|
||||
/** 入库单:送货单位 = 装货客户 */
|
||||
export function resolveInboundDeliveryUnit(plan: Plan): string {
|
||||
const loadName = String(plan.load?.customerName || '').trim()
|
||||
if (loadName) return loadName
|
||||
return String(plan.supplierName || '').trim() || String(plan.customerName || '').trim()
|
||||
}
|
||||
@@ -160,6 +160,10 @@ function buildReceivingUnit(plan: Plan): string {
|
||||
return plan.customerName?.trim() || plan.destinationName?.trim() || ''
|
||||
}
|
||||
|
||||
function buildReceiveContact(plan: Plan): string {
|
||||
return plan.deliveryContact?.trim() || plan.contactPhone?.trim() || plan.contactName?.trim() || ''
|
||||
}
|
||||
|
||||
function formatDeliverySlipProductGridCellContent(content: string): string {
|
||||
const plain = content
|
||||
.trim()
|
||||
@@ -1856,7 +1860,7 @@ export function replaceDeliverySlipPlaceholders(
|
||||
'{{companyName}}': DELIVERY_SLIP_DEFAULTS.companyName,
|
||||
'{{receivingUnit}}': isBlank ? '' : buildReceivingUnit(plan),
|
||||
'{{planNo}}': isBlank ? '' : plan.planNo || '',
|
||||
'{{receiveContact}}': '',
|
||||
'{{receiveContact}}': isBlank ? '' : buildReceiveContact(plan),
|
||||
'{{driverInfo}}': '',
|
||||
'{{planDateChinese}}': isBlank ? '' : formatPlanDateChinese(plan.planDate),
|
||||
'{{productTable}}': buildProductRows(plan.products, plan.planNo || '', ctx, options),
|
||||
|
||||
@@ -0,0 +1,252 @@
|
||||
import type { PlanDelivery, PlanLoad, PlanProduct, PlanStopProduct } from '@/api/pl'
|
||||
import {
|
||||
appendAmapNavLine,
|
||||
buildAmapNavigationUrlWithFallback
|
||||
} from '@/utils/amap/navigation'
|
||||
import { formatDate } from '@/utils/format'
|
||||
import { formatPlanProductListText } from '@/utils/pl-display'
|
||||
|
||||
export type DriverSummaryStopBlock = {
|
||||
label: string
|
||||
customerName?: string
|
||||
stopTime?: string
|
||||
address?: string
|
||||
lng?: number | null
|
||||
lat?: number | null
|
||||
contact?: string
|
||||
notes?: string
|
||||
productLines: string[]
|
||||
}
|
||||
|
||||
type DriverSummaryPlan = {
|
||||
planNo?: string
|
||||
licensePlate?: string
|
||||
pickupTime?: string
|
||||
planDate?: string
|
||||
personnelSummary?: string
|
||||
pickupAddress?: string
|
||||
pickupLng?: number | null
|
||||
pickupLat?: number | null
|
||||
pickupContact?: string
|
||||
pickupNotes?: string
|
||||
destinationAddress?: string
|
||||
destinationName?: string
|
||||
destinationLng?: number | null
|
||||
destinationLat?: number | null
|
||||
deliveryContact?: string
|
||||
destinationNotes?: string
|
||||
startPoint?: string
|
||||
endPoint?: string
|
||||
load?: PlanLoad | null
|
||||
deliveries?: PlanDelivery[] | null
|
||||
}
|
||||
|
||||
function formatDriverStopProductLine(
|
||||
product: PlanStopProduct,
|
||||
getUnitLabel?: (unit: string) => string
|
||||
) {
|
||||
return formatPlanProductListText(
|
||||
{
|
||||
productName: product.productName,
|
||||
model: product.model,
|
||||
packageSpec: product.packageSpec,
|
||||
unit: product.unit,
|
||||
quantity: product.planQty
|
||||
},
|
||||
getUnitLabel,
|
||||
{ usePlannedQuantity: true }
|
||||
)
|
||||
}
|
||||
|
||||
function formatPlanLevelProductLines(
|
||||
products: PlanProduct[],
|
||||
getUnitLabel?: (unit: string) => string
|
||||
) {
|
||||
return products
|
||||
.map((product) => formatPlanProductListText(product, getUnitLabel, { usePlannedQuantity: true }))
|
||||
.filter(Boolean)
|
||||
}
|
||||
|
||||
function appendDriverStopBlockLines(lines: string[], stop: DriverSummaryStopBlock) {
|
||||
lines.push(`【${stop.label} · ${stop.customerName || '—'}】`)
|
||||
if (stop.stopTime) {
|
||||
lines.push(`时间:${stop.stopTime}`)
|
||||
}
|
||||
if (stop.address) {
|
||||
lines.push(`地址:${stop.address}`)
|
||||
}
|
||||
appendAmapNavLine(
|
||||
lines,
|
||||
'导航',
|
||||
buildAmapNavigationUrlWithFallback({
|
||||
lng: stop.lng,
|
||||
lat: stop.lat,
|
||||
address: stop.address,
|
||||
name: stop.label
|
||||
})
|
||||
)
|
||||
if (stop.contact) {
|
||||
lines.push(`联系方式:${stop.contact}`)
|
||||
}
|
||||
if (stop.notes) {
|
||||
lines.push(`注意事项:${stop.notes}`)
|
||||
}
|
||||
if (stop.productLines.length) {
|
||||
stop.productLines.forEach((line) => lines.push(`产品:${line}`))
|
||||
} else {
|
||||
lines.push('产品:—')
|
||||
}
|
||||
}
|
||||
|
||||
export function buildDriverStopBlocksFromPlan(
|
||||
plan?: DriverSummaryPlan | null,
|
||||
getUnitLabel?: (unit: string) => string
|
||||
): DriverSummaryStopBlock[] {
|
||||
if (!plan) return []
|
||||
const blocks: DriverSummaryStopBlock[] = []
|
||||
const load = plan.load
|
||||
if (load) {
|
||||
blocks.push({
|
||||
label: '装货',
|
||||
customerName: load.customerName || undefined,
|
||||
stopTime: formatDate(load.loadTime) || undefined,
|
||||
address: load.address || undefined,
|
||||
lng: load.lng,
|
||||
lat: load.lat,
|
||||
contact: load.contact || undefined,
|
||||
notes: load.notes || undefined,
|
||||
productLines: (load.products || []).map((product) =>
|
||||
formatDriverStopProductLine(product, getUnitLabel)
|
||||
)
|
||||
})
|
||||
}
|
||||
for (const delivery of plan.deliveries || []) {
|
||||
const seq = delivery.seq != null ? Number(delivery.seq) : 0
|
||||
blocks.push({
|
||||
label: seq > 0 ? `送货 #${seq}` : '送货',
|
||||
customerName: delivery.customerName || undefined,
|
||||
stopTime: formatDate(delivery.deliveryTime) || undefined,
|
||||
address: delivery.address || undefined,
|
||||
lng: delivery.lng,
|
||||
lat: delivery.lat,
|
||||
contact: delivery.contact || undefined,
|
||||
notes: delivery.notes || undefined,
|
||||
productLines: (delivery.products || []).map((product) =>
|
||||
formatDriverStopProductLine(product, getUnitLabel)
|
||||
)
|
||||
})
|
||||
}
|
||||
return blocks
|
||||
}
|
||||
|
||||
function buildLegacyDriverStopBlocks(
|
||||
plan: DriverSummaryPlan,
|
||||
overrides: {
|
||||
pickupAddress?: string
|
||||
pickupLng?: number | null
|
||||
pickupLat?: number | null
|
||||
pickupContact?: string
|
||||
pickupNotes?: string
|
||||
destinationAddress?: string
|
||||
destinationLng?: number | null
|
||||
destinationLat?: number | null
|
||||
deliveryContact?: string
|
||||
destinationNotes?: string
|
||||
startPoint?: string
|
||||
endPoint?: string
|
||||
},
|
||||
productLines: string[]
|
||||
): DriverSummaryStopBlock[] {
|
||||
const pickupAddress =
|
||||
overrides.pickupAddress || plan.pickupAddress || overrides.startPoint || plan.startPoint
|
||||
const destinationAddress =
|
||||
overrides.destinationAddress ||
|
||||
plan.destinationAddress ||
|
||||
plan.destinationName ||
|
||||
overrides.endPoint ||
|
||||
plan.endPoint
|
||||
const blocks: DriverSummaryStopBlock[] = []
|
||||
if (pickupAddress) {
|
||||
blocks.push({
|
||||
label: '取货',
|
||||
customerName: plan.load?.customerName || undefined,
|
||||
stopTime: formatDate(plan.pickupTime) || undefined,
|
||||
address: pickupAddress,
|
||||
lng: overrides.pickupLng ?? plan.pickupLng,
|
||||
lat: overrides.pickupLat ?? plan.pickupLat,
|
||||
contact: overrides.pickupContact || plan.pickupContact || undefined,
|
||||
notes: overrides.pickupNotes || plan.pickupNotes || undefined,
|
||||
productLines: productLines.length ? productLines : []
|
||||
})
|
||||
}
|
||||
if (destinationAddress) {
|
||||
blocks.push({
|
||||
label: '送货',
|
||||
customerName: undefined,
|
||||
stopTime: undefined,
|
||||
address: destinationAddress,
|
||||
lng: overrides.destinationLng ?? plan.destinationLng,
|
||||
lat: overrides.destinationLat ?? plan.destinationLat,
|
||||
contact: overrides.deliveryContact || plan.deliveryContact || undefined,
|
||||
notes: overrides.destinationNotes || plan.destinationNotes || undefined,
|
||||
productLines: []
|
||||
})
|
||||
}
|
||||
return blocks
|
||||
}
|
||||
|
||||
export function buildDriverSummaryFromPlan(options: {
|
||||
plan?: DriverSummaryPlan | null
|
||||
planNo?: string
|
||||
licensePlate?: string
|
||||
pickupTime?: string
|
||||
planDate?: string
|
||||
personnelSummary?: string
|
||||
driverUrl?: string
|
||||
products?: PlanProduct[]
|
||||
stopBlocks?: DriverSummaryStopBlock[]
|
||||
getUnitLabel?: (unit: string) => string
|
||||
pickupAddress?: string
|
||||
pickupLng?: number | null
|
||||
pickupLat?: number | null
|
||||
destinationAddress?: string
|
||||
destinationLng?: number | null
|
||||
destinationLat?: number | null
|
||||
pickupContact?: string
|
||||
pickupNotes?: string
|
||||
deliveryContact?: string
|
||||
destinationNotes?: string
|
||||
startPoint?: string
|
||||
endPoint?: string
|
||||
}) {
|
||||
const plan = options.plan || {}
|
||||
const plate = options.licensePlate || plan.licensePlate || '—'
|
||||
const lines = [`【${plate} - 运输计划】`]
|
||||
lines.push(`计划号:${options.planNo || plan.planNo || '—'}`)
|
||||
lines.push(`车牌:${plate}`)
|
||||
const time = formatDate(options.pickupTime || plan.pickupTime) || options.planDate || plan.planDate
|
||||
if (time) lines.push(`时间:${time}`)
|
||||
|
||||
const productLines = formatPlanLevelProductLines(options.products || [], options.getUnitLabel)
|
||||
let stopBlocks =
|
||||
options.stopBlocks ||
|
||||
buildDriverStopBlocksFromPlan(plan, options.getUnitLabel)
|
||||
if (!stopBlocks.length) {
|
||||
stopBlocks = buildLegacyDriverStopBlocks(plan, options, productLines)
|
||||
}
|
||||
|
||||
if (stopBlocks.length) {
|
||||
lines.push('')
|
||||
stopBlocks.forEach((stop, index) => {
|
||||
if (index > 0) lines.push('')
|
||||
appendDriverStopBlockLines(lines, stop)
|
||||
})
|
||||
} else if (productLines.length) {
|
||||
lines.push('')
|
||||
lines.push(`产品:${productLines.join(';')}`)
|
||||
}
|
||||
|
||||
lines.push('')
|
||||
lines.push(`司机链接:${options.driverUrl || '—'}`)
|
||||
return lines.join('\n')
|
||||
}
|
||||
@@ -151,7 +151,9 @@ function formatQty(value?: number | string | null): string {
|
||||
}
|
||||
|
||||
function buildDeliveryUnit(plan: Plan): string {
|
||||
return plan.customerName?.trim() || plan.destinationName?.trim() || ''
|
||||
const loadName = String(plan.load?.customerName || '').trim()
|
||||
if (loadName) return loadName
|
||||
return plan.supplierName?.trim() || plan.customerName?.trim() || plan.destinationName?.trim() || ''
|
||||
}
|
||||
|
||||
function formatInboundSlipProductGridCellContent(content: string): string {
|
||||
|
||||
@@ -8,3 +8,29 @@ export function isPlInternalCustomerName(name?: string | null): boolean {
|
||||
const n = (name || '').trim()
|
||||
return (PL_INTERNAL_CUSTOMER_NAMES as readonly string[]).includes(n)
|
||||
}
|
||||
|
||||
/** 装货或送货段任一段客户为山峡/云栋时,需要现场链接。 */
|
||||
export function planRequiresSiteLink(
|
||||
plan?: {
|
||||
load?: { customerName?: string | null } | null
|
||||
deliveries?: { customerName?: string | null }[] | null
|
||||
supplierName?: string | null
|
||||
customerName?: string | null
|
||||
destinationName?: string | null
|
||||
} | null
|
||||
): boolean {
|
||||
if (!plan) return false
|
||||
if (plan.load) {
|
||||
if (isPlInternalCustomerName(plan.load.customerName)) return true
|
||||
} else if (isPlInternalCustomerName(plan.supplierName)) {
|
||||
return true
|
||||
}
|
||||
const deliveries = plan.deliveries || []
|
||||
if (deliveries.length) {
|
||||
return deliveries.some(item => isPlInternalCustomerName(item.customerName))
|
||||
}
|
||||
return (
|
||||
isPlInternalCustomerName(plan.customerName) ||
|
||||
isPlInternalCustomerName(plan.destinationName)
|
||||
)
|
||||
}
|
||||
@@ -0,0 +1,245 @@
|
||||
import type { Plan, PlanDelivery, PlanLoad, PlanProduct, PlanStopProduct } from '@/api/pl'
|
||||
import { formatDate } from '@/utils/format'
|
||||
import {
|
||||
planContractSideLines,
|
||||
type PlanContractDisplayLine
|
||||
} from '@/utils/pl-plan-contract-display'
|
||||
import { mapLegacyPlanToStops } from '@/utils/pl-plan-stop-form'
|
||||
|
||||
export type PlPlanListDisplayRowKind = 'load' | 'delivery'
|
||||
|
||||
export type PlPlanListColumnScope = 'plan' | 'stop'
|
||||
|
||||
export interface PlPlanListDisplayRow {
|
||||
rowKey: string
|
||||
plan: Plan
|
||||
kind: PlPlanListDisplayRowKind
|
||||
stop: PlanLoad | PlanDelivery
|
||||
deliverySeq?: number
|
||||
/** 当前页内计划序号(0-based),用于整单斑马纹 */
|
||||
planListIndex: number
|
||||
isPlanFirstRow: boolean
|
||||
planRowSpan: number
|
||||
isPlanLastRow: boolean
|
||||
}
|
||||
|
||||
const PLAN_FIXED_MERGE_COL_COUNT = 3
|
||||
|
||||
export function resolvePlanStopsForList(plan: Plan): {
|
||||
load: PlanLoad
|
||||
deliveries: PlanDelivery[]
|
||||
} {
|
||||
if (plan.load && (plan.deliveries?.length ?? 0) > 0) {
|
||||
return {
|
||||
load: plan.load,
|
||||
deliveries: plan.deliveries || []
|
||||
}
|
||||
}
|
||||
const legacy = mapLegacyPlanToStops(plan)
|
||||
return {
|
||||
load: legacy.load as PlanLoad,
|
||||
deliveries: legacy.deliveries as PlanDelivery[]
|
||||
}
|
||||
}
|
||||
|
||||
export function flattenPlanListRows(plans: Plan[]): PlPlanListDisplayRow[] {
|
||||
const rows: PlPlanListDisplayRow[] = []
|
||||
plans.forEach((plan, planListIndex) => {
|
||||
const { load, deliveries } = resolvePlanStopsForList(plan)
|
||||
const planRowSpan = 1 + deliveries.length
|
||||
rows.push({
|
||||
rowKey: `${plan.id}-load`,
|
||||
plan,
|
||||
kind: 'load',
|
||||
stop: load,
|
||||
planListIndex,
|
||||
isPlanFirstRow: true,
|
||||
planRowSpan,
|
||||
isPlanLastRow: deliveries.length === 0
|
||||
})
|
||||
deliveries.forEach((delivery, index) => {
|
||||
rows.push({
|
||||
rowKey: `${plan.id}-delivery-${delivery.seq ?? index + 1}`,
|
||||
plan,
|
||||
kind: 'delivery',
|
||||
stop: delivery,
|
||||
deliverySeq: delivery.seq ?? index + 1,
|
||||
planListIndex,
|
||||
isPlanFirstRow: false,
|
||||
planRowSpan,
|
||||
isPlanLastRow: index === deliveries.length - 1
|
||||
})
|
||||
})
|
||||
})
|
||||
return rows
|
||||
}
|
||||
|
||||
export function getPlanListDisplayIndex(
|
||||
displayRows: PlPlanListDisplayRow[],
|
||||
displayRowIndex: number,
|
||||
page: number,
|
||||
pageSize: number
|
||||
): number {
|
||||
const row = displayRows[displayRowIndex]
|
||||
if (!row?.isPlanFirstRow) return 0
|
||||
let planIndex = 0
|
||||
for (let i = 0; i < displayRowIndex; i++) {
|
||||
if (displayRows[i]?.isPlanFirstRow) planIndex++
|
||||
}
|
||||
return (page - 1) * pageSize + planIndex + 1
|
||||
}
|
||||
|
||||
export function isPlPlanListPlanMergeColumn(
|
||||
columnIndex: number,
|
||||
visiblePlanProps: string[]
|
||||
): boolean {
|
||||
if (columnIndex < PLAN_FIXED_MERGE_COL_COUNT) return true
|
||||
const planColIndex = columnIndex - PLAN_FIXED_MERGE_COL_COUNT
|
||||
return planColIndex >= 0 && planColIndex < visiblePlanProps.length
|
||||
}
|
||||
|
||||
export function buildPlPlanListSpanMethod(
|
||||
visiblePlanProps: string[]
|
||||
): (args: {
|
||||
row: PlPlanListDisplayRow
|
||||
column: { type?: string; property?: string }
|
||||
rowIndex: number
|
||||
columnIndex: number
|
||||
}) => { rowspan: number; colspan: number } | undefined {
|
||||
const planMergeCount = PLAN_FIXED_MERGE_COL_COUNT + visiblePlanProps.length
|
||||
return ({ row, columnIndex }) => {
|
||||
if (columnIndex >= planMergeCount) return undefined
|
||||
if (row.isPlanFirstRow) {
|
||||
return { rowspan: row.planRowSpan, colspan: 1 }
|
||||
}
|
||||
return { rowspan: 0, colspan: 0 }
|
||||
}
|
||||
}
|
||||
|
||||
export function getPlPlanListRowClassName({ row }: { row: PlPlanListDisplayRow }): string {
|
||||
const classes = [row.kind === 'load' ? 'pl-plan-list-row--load' : 'pl-plan-list-row--delivery']
|
||||
if (row.planListIndex % 2 === 1) classes.push('pl-plan-list-row--plan-striped')
|
||||
if (row.isPlanLastRow) classes.push('pl-plan-list-row--plan-end')
|
||||
return classes.join(' ')
|
||||
}
|
||||
|
||||
export function getStopKindLabel(row: PlPlanListDisplayRow): string {
|
||||
if (row.kind === 'load') return '装货'
|
||||
return `送货 #${row.deliverySeq ?? 1}`
|
||||
}
|
||||
|
||||
export function formatStopDibangLabel(stop: PlanLoad | PlanDelivery): string {
|
||||
if (!stop.generateDibang) return ''
|
||||
const direction = (stop.dibangDirection || '').trim()
|
||||
if (direction === 'outbound') return '出库'
|
||||
if (direction === 'inbound') return '入库'
|
||||
if (direction === 'none') return '无'
|
||||
return '是'
|
||||
}
|
||||
|
||||
export function getStopDibangTagType(
|
||||
stop: PlanLoad | PlanDelivery
|
||||
): 'success' | 'info' | 'warning' | undefined {
|
||||
if (!stop.generateDibang) return undefined
|
||||
const direction = (stop.dibangDirection || '').trim()
|
||||
if (direction === 'outbound') return 'success'
|
||||
if (direction === 'inbound') return 'success'
|
||||
return 'info'
|
||||
}
|
||||
|
||||
export function getStopAddress(row: PlPlanListDisplayRow): string {
|
||||
return (row.stop.address || '').trim() || '—'
|
||||
}
|
||||
|
||||
export function getStopTime(row: PlPlanListDisplayRow): string {
|
||||
const raw =
|
||||
row.kind === 'load' ? (row.stop as PlanLoad).loadTime : (row.stop as PlanDelivery).deliveryTime
|
||||
const text = (raw || '').trim()
|
||||
if (!text) return '—'
|
||||
return formatDate(text) || text.slice(0, 10) || '—'
|
||||
}
|
||||
|
||||
export function getStopCustomerName(row: PlPlanListDisplayRow): string {
|
||||
return (row.stop.customerName || '').trim() || '—'
|
||||
}
|
||||
|
||||
/** 装货行展示供方;送货行留空 */
|
||||
export function getStopSupplierNameDisplay(row: PlPlanListDisplayRow): string {
|
||||
if (row.kind !== 'load') return '—'
|
||||
return (row.plan.supplierName || row.stop.customerName || '').trim() || '—'
|
||||
}
|
||||
|
||||
/** 送货行展示需方;装货行留空 */
|
||||
export function getStopDemanderNameDisplay(row: PlPlanListDisplayRow): string {
|
||||
if (row.kind !== 'delivery') return '—'
|
||||
return (row.stop.customerName || row.plan.customerName || '').trim() || '—'
|
||||
}
|
||||
|
||||
export function getStopContractLines(row: PlPlanListDisplayRow): PlanContractDisplayLine[] {
|
||||
if (row.kind === 'load') {
|
||||
return planContractSideLines('供', row.stop.contracts, row.stop.customerName)
|
||||
}
|
||||
return planContractSideLines('需', row.stop.contracts, row.stop.customerName)
|
||||
}
|
||||
|
||||
export function getStopProducts(row: PlPlanListDisplayRow): PlanStopProduct[] {
|
||||
return row.stop.products || []
|
||||
}
|
||||
|
||||
/** 段内危化证展示:按 planProductId 关联计划产品行 */
|
||||
export function resolveStopCertProducts(
|
||||
plan: Plan,
|
||||
stopProducts: PlanStopProduct[]
|
||||
): PlanProduct[] {
|
||||
const planProducts = plan.products || []
|
||||
const resolved: PlanProduct[] = []
|
||||
for (const stopProduct of stopProducts) {
|
||||
const match =
|
||||
planProducts.find(
|
||||
(item) =>
|
||||
stopProduct.planProductId &&
|
||||
item.id &&
|
||||
String(item.id) === String(stopProduct.planProductId)
|
||||
) || planProducts.find((item) => String(item.productId) === String(stopProduct.productId))
|
||||
if (match) {
|
||||
resolved.push(match)
|
||||
continue
|
||||
}
|
||||
resolved.push({
|
||||
id: stopProduct.planProductId || stopProduct.id || stopProduct.productId,
|
||||
planId: plan.id,
|
||||
productId: stopProduct.productId,
|
||||
productNo: stopProduct.productNo,
|
||||
productName: stopProduct.productName,
|
||||
model: stopProduct.model,
|
||||
unit: stopProduct.unit || '吨',
|
||||
packageSpec: stopProduct.packageSpec,
|
||||
deliveryMethod: stopProduct.deliveryMethod,
|
||||
quantity: stopProduct.planQty,
|
||||
isExplosive: 0,
|
||||
isToxic: 0
|
||||
})
|
||||
}
|
||||
return resolved
|
||||
}
|
||||
|
||||
export function sumStopProductsField(
|
||||
stopProducts: PlanStopProduct[],
|
||||
field: 'planQty' | 'inboundQty' | 'outboundQty'
|
||||
): number {
|
||||
return stopProducts.reduce((sum, item) => sum + (Number(item[field]) || 0), 0)
|
||||
}
|
||||
|
||||
export function sumStopActualQty(plan: Plan, stopProducts: PlanStopProduct[]): number {
|
||||
const planProducts = plan.products || []
|
||||
return stopProducts.reduce((sum, stopProduct) => {
|
||||
const match =
|
||||
planProducts.find(
|
||||
(item) =>
|
||||
stopProduct.planProductId &&
|
||||
item.id &&
|
||||
String(item.id) === String(stopProduct.planProductId)
|
||||
) || planProducts.find((item) => String(item.productId) === String(stopProduct.productId))
|
||||
return sum + (Number(match?.actualQty) || 0)
|
||||
}, 0)
|
||||
}
|
||||
@@ -0,0 +1,701 @@
|
||||
import type { Plan, PlanContractLink, PlanDelivery, PlanLoad, PlanStopProduct } from '@/api/pl'
|
||||
import type { PlanFormProductRow } from '@/composables/usePlContractToPlan'
|
||||
import type { BrandOption } from '@/utils/crm-product-brand'
|
||||
import { formatBrandConstraintLabel } from '@/utils/crm-product-brand'
|
||||
import { isPlInternalCustomerName } from '@/utils/pl-internal-customer'
|
||||
|
||||
export interface PlanStopProductFormRow {
|
||||
id?: string
|
||||
planProductId?: string
|
||||
productId: string
|
||||
productNo: string
|
||||
productName: string
|
||||
/** 展示用:主数据标准名 */
|
||||
standardProductName?: string
|
||||
/** 展示用:别名 */
|
||||
aliasName?: string
|
||||
aliasOptions?: string[]
|
||||
brandMode?: string
|
||||
brandId?: string
|
||||
brandName?: string
|
||||
brandOptions?: BrandOption[]
|
||||
model?: string
|
||||
unit: string
|
||||
packageSpec?: string
|
||||
deliveryMethod?: string
|
||||
planQty?: number
|
||||
/** 装货段归档:入库数量即实际数量 */
|
||||
inboundQty?: number
|
||||
inboundPrice?: number
|
||||
inboundAmount?: number
|
||||
/** 送货段归档:出库数量即实际数量 */
|
||||
outboundQty?: number
|
||||
outboundPrice?: number
|
||||
outboundAmount?: number
|
||||
remark?: string
|
||||
isExplosive?: number
|
||||
isToxic?: number
|
||||
}
|
||||
|
||||
/** 段次查看/归档:装货段取 inbound,送货段取 outbound */
|
||||
export function resolveStopActualQty(
|
||||
row: PlanStopProductFormRow,
|
||||
stopType: 'load' | 'delivery'
|
||||
): number | undefined {
|
||||
const raw = stopType === 'load' ? row.inboundQty : row.outboundQty
|
||||
return raw != null ? Number(raw) : undefined
|
||||
}
|
||||
|
||||
export function resolveStopUnitPrice(
|
||||
row: PlanStopProductFormRow,
|
||||
stopType: 'load' | 'delivery'
|
||||
): number | undefined {
|
||||
const raw = stopType === 'load' ? row.inboundPrice : row.outboundPrice
|
||||
return raw != null ? Number(raw) : undefined
|
||||
}
|
||||
|
||||
export function resolveStopArchiveAmount(
|
||||
row: PlanStopProductFormRow,
|
||||
stopType: 'load' | 'delivery'
|
||||
): number | undefined {
|
||||
const stored = stopType === 'load' ? row.inboundAmount : row.outboundAmount
|
||||
if (stored != null) {
|
||||
const n = Number(stored)
|
||||
return Number.isFinite(n) ? n : undefined
|
||||
}
|
||||
const qty = resolveStopActualQty(row, stopType)
|
||||
const price = resolveStopUnitPrice(row, stopType)
|
||||
if (qty == null || price == null) return undefined
|
||||
const amount = qty * price
|
||||
return Number.isFinite(amount) ? amount : undefined
|
||||
}
|
||||
|
||||
export function formatStopArchiveAmount(
|
||||
row: PlanStopProductFormRow,
|
||||
stopType: 'load' | 'delivery'
|
||||
): string {
|
||||
const amount = resolveStopArchiveAmount(row, stopType)
|
||||
return amount != null ? amount.toFixed(2) : '—'
|
||||
}
|
||||
|
||||
export interface PlanLoadForm {
|
||||
customerId: string
|
||||
customerName: string
|
||||
address: string
|
||||
lng: number | null
|
||||
lat: number | null
|
||||
loadTime: string
|
||||
contact: string
|
||||
notes: string
|
||||
generateDibang: number
|
||||
dibangDirection: string
|
||||
contracts: PlanContractLink[]
|
||||
products: PlanStopProductFormRow[]
|
||||
}
|
||||
|
||||
export interface PlanDeliveryForm {
|
||||
seq: number
|
||||
customerId: string
|
||||
customerName: string
|
||||
address: string
|
||||
lng: number | null
|
||||
lat: number | null
|
||||
deliveryTime: string
|
||||
contact: string
|
||||
notes: string
|
||||
generateDibang: number
|
||||
dibangDirection: string
|
||||
contracts: PlanContractLink[]
|
||||
products: PlanStopProductFormRow[]
|
||||
}
|
||||
|
||||
/** 地磅默认勾选以装货客户是否为内部客户(山峡/云栋)为准,与送货段客户无关。 */
|
||||
export function resolveStopDibangDefaults(
|
||||
loadCustomerName?: string | null,
|
||||
stopType: 'load' | 'delivery' = 'load'
|
||||
): { generateDibang: number; dibangDirection: string } {
|
||||
if (!isPlInternalCustomerName(loadCustomerName)) {
|
||||
return { generateDibang: 0, dibangDirection: 'none' }
|
||||
}
|
||||
if (stopType === 'load') {
|
||||
return { generateDibang: 1, dibangDirection: 'outbound' }
|
||||
}
|
||||
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
|
||||
}))
|
||||
}
|
||||
|
||||
export function createStopProductsFromPlanProducts(
|
||||
products: PlanFormProductRow[],
|
||||
qtyField: 'quantity' | 'actualQty' = 'quantity'
|
||||
): PlanStopProductFormRow[] {
|
||||
return products.map((item) => ({
|
||||
planProductId: item.id,
|
||||
productId: item.productId,
|
||||
productNo: item.productNo,
|
||||
productName: item.productName,
|
||||
standardProductName: item.standardProductName || item.productName,
|
||||
aliasName: item.aliasName,
|
||||
aliasOptions: item.aliasOptions ? [...item.aliasOptions] : undefined,
|
||||
brandMode: item.brandMode,
|
||||
brandId: item.brandId,
|
||||
brandName: item.brandName,
|
||||
brandOptions: item.brandOptions ? [...item.brandOptions] : undefined,
|
||||
model: item.model,
|
||||
unit: item.unit || '吨',
|
||||
packageSpec: item.packageSpec,
|
||||
deliveryMethod: item.deliveryMethod,
|
||||
planQty: Number(item[qtyField] ?? item.quantity ?? 0),
|
||||
remark: item.remark,
|
||||
isExplosive: item.isExplosive,
|
||||
isToxic: item.isToxic
|
||||
}))
|
||||
}
|
||||
|
||||
function matchPrevStopProduct(
|
||||
stopProducts: PlanStopProductFormRow[],
|
||||
planRow: PlanFormProductRow,
|
||||
used: Set<number>
|
||||
): PlanStopProductFormRow | undefined {
|
||||
if (planRow.id) {
|
||||
const byPlanProductId = stopProducts.findIndex(
|
||||
(row, index) =>
|
||||
!used.has(index) && row.planProductId && String(row.planProductId) === String(planRow.id)
|
||||
)
|
||||
if (byPlanProductId >= 0) {
|
||||
used.add(byPlanProductId)
|
||||
return stopProducts[byPlanProductId]
|
||||
}
|
||||
}
|
||||
const byProductId = stopProducts.findIndex(
|
||||
(row, index) => !used.has(index) && String(row.productId) === String(planRow.productId)
|
||||
)
|
||||
if (byProductId >= 0) {
|
||||
used.add(byProductId)
|
||||
return stopProducts[byProductId]
|
||||
}
|
||||
return undefined
|
||||
}
|
||||
|
||||
/**
|
||||
* 按计划产品重建段产品列表:增删对齐计划层;共享字段取自计划;
|
||||
* 可选保留段内已改的数量 / 备注。
|
||||
*/
|
||||
export function reconcileStopProductsWithPlan(
|
||||
stopProducts: PlanStopProductFormRow[],
|
||||
planProducts: PlanFormProductRow[],
|
||||
options?: {
|
||||
preserveQty?: boolean
|
||||
preserveRemark?: boolean
|
||||
}
|
||||
): PlanStopProductFormRow[] {
|
||||
const preserveQty = options?.preserveQty !== false
|
||||
const preserveRemark = options?.preserveRemark !== false
|
||||
const used = new Set<number>()
|
||||
const nextRows = createStopProductsFromPlanProducts(planProducts)
|
||||
return nextRows.map((row, index) => {
|
||||
const planRow = planProducts[index]
|
||||
const prev = planRow ? matchPrevStopProduct(stopProducts, planRow, used) : undefined
|
||||
if (!prev) return row
|
||||
return {
|
||||
...row,
|
||||
planQty: preserveQty ? (prev.planQty ?? row.planQty) : row.planQty,
|
||||
remark: preserveRemark ? (prev.remark ?? row.remark) : row.remark
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
/** 用计划产品行补齐装货/送货产品表展示字段(别名、品牌等) */
|
||||
export function sumStopProductsPlanQty(products: PlanStopProductFormRow[]): number {
|
||||
return products.reduce((sum, row) => sum + Number(row.planQty ?? 0), 0)
|
||||
}
|
||||
|
||||
/** 段内紧凑表「产品」列副行:别名 · 品牌 · 规格 · 单位 */
|
||||
export function formatStopProductMetaSubline(
|
||||
row: PlanStopProductFormRow,
|
||||
unitLabel?: string
|
||||
): string {
|
||||
const parts: string[] = []
|
||||
if (row.aliasName) parts.push(`别名:${row.aliasName}`)
|
||||
const brand = formatBrandConstraintLabel(row.brandMode, row.brandName)
|
||||
if (brand && brand !== '—') parts.push(`品牌:${brand}`)
|
||||
if (row.model) parts.push(row.model)
|
||||
const unit = unitLabel || row.unit
|
||||
if (unit) parts.push(unit)
|
||||
return parts.join(' · ')
|
||||
}
|
||||
|
||||
export function enrichStopProductsDisplayFromPlan(
|
||||
stopProducts: PlanStopProductFormRow[],
|
||||
planProducts: Array<{
|
||||
id?: string
|
||||
productId: string
|
||||
productNo?: string
|
||||
productName?: string
|
||||
standardProductName?: string
|
||||
aliasName?: string
|
||||
aliasOptions?: string[]
|
||||
brandMode?: string
|
||||
brandId?: string
|
||||
brandName?: string
|
||||
brandOptions?: BrandOption[]
|
||||
model?: string
|
||||
unit?: string
|
||||
packageSpec?: string
|
||||
deliveryMethod?: string
|
||||
quantity?: number
|
||||
isExplosive?: number
|
||||
isToxic?: number
|
||||
}>
|
||||
): PlanStopProductFormRow[] {
|
||||
return stopProducts.map((row) => {
|
||||
const match =
|
||||
planProducts.find(
|
||||
(p) => row.planProductId && p.id && String(p.id) === String(row.planProductId)
|
||||
) || planProducts.find((p) => String(p.productId) === String(row.productId))
|
||||
if (!match) return row
|
||||
const planQty =
|
||||
row.planQty != null && Number.isFinite(Number(row.planQty))
|
||||
? Number(row.planQty)
|
||||
: match.quantity != null
|
||||
? Number(match.quantity)
|
||||
: row.planQty
|
||||
return {
|
||||
...row,
|
||||
productNo: row.productNo || match.productNo || row.productNo,
|
||||
standardProductName: match.standardProductName || match.productName || row.productName,
|
||||
aliasName: match.aliasName ?? row.aliasName,
|
||||
aliasOptions: match.aliasOptions?.length ? [...match.aliasOptions] : row.aliasOptions,
|
||||
brandMode: match.brandMode ?? row.brandMode,
|
||||
brandId: match.brandId ?? row.brandId,
|
||||
brandName: match.brandName ?? row.brandName,
|
||||
brandOptions: match.brandOptions?.length ? [...match.brandOptions] : row.brandOptions,
|
||||
model: row.model || match.model,
|
||||
unit: row.unit || match.unit || '吨',
|
||||
packageSpec: row.packageSpec || match.packageSpec,
|
||||
deliveryMethod: row.deliveryMethod || match.deliveryMethod,
|
||||
planQty,
|
||||
isExplosive: match.isExplosive ?? row.isExplosive,
|
||||
isToxic: match.isToxic ?? row.isToxic
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
/** 查看态:段产品为空时回退计划产品,再补齐展示字段(与编辑弹窗 bootstrap 一致) */
|
||||
export function resolveStopProductsForView(
|
||||
stopProducts: PlanStopProductFormRow[] | undefined | null,
|
||||
planProducts: PlanFormProductRow[]
|
||||
): PlanStopProductFormRow[] {
|
||||
const rows = stopProducts?.length
|
||||
? stopProducts
|
||||
: planProducts.length
|
||||
? createStopProductsFromPlanProducts(planProducts)
|
||||
: []
|
||||
return enrichStopProductsDisplayFromPlan(rows, planProducts)
|
||||
}
|
||||
|
||||
export function createEmptyLoadForm(): PlanLoadForm {
|
||||
return {
|
||||
customerId: '',
|
||||
customerName: '',
|
||||
address: '',
|
||||
lng: null,
|
||||
lat: null,
|
||||
loadTime: '',
|
||||
contact: '',
|
||||
notes: '',
|
||||
generateDibang: 0,
|
||||
dibangDirection: 'none',
|
||||
contracts: [],
|
||||
products: []
|
||||
}
|
||||
}
|
||||
|
||||
export function createEmptyDeliveryForm(
|
||||
seq = 1,
|
||||
loadCustomerName?: string | null
|
||||
): PlanDeliveryForm {
|
||||
const defaults = resolveStopDibangDefaults(loadCustomerName, 'delivery')
|
||||
return {
|
||||
seq,
|
||||
customerId: '',
|
||||
customerName: '',
|
||||
address: '',
|
||||
lng: null,
|
||||
lat: null,
|
||||
deliveryTime: '',
|
||||
contact: '',
|
||||
notes: '',
|
||||
generateDibang: defaults.generateDibang,
|
||||
dibangDirection: defaults.dibangDirection,
|
||||
contracts: [],
|
||||
products: []
|
||||
}
|
||||
}
|
||||
|
||||
function mapStopProductFromApi(row: PlanStopProduct): PlanStopProductFormRow {
|
||||
return {
|
||||
id: row.id,
|
||||
planProductId: row.planProductId,
|
||||
productId: row.productId,
|
||||
productNo: row.productNo,
|
||||
productName: row.productName,
|
||||
model: row.model,
|
||||
unit: row.unit || '吨',
|
||||
packageSpec: row.packageSpec,
|
||||
deliveryMethod: row.deliveryMethod,
|
||||
planQty: row.planQty != null ? Number(row.planQty) : undefined,
|
||||
inboundQty: row.inboundQty != null ? Number(row.inboundQty) : undefined,
|
||||
inboundPrice: row.inboundPrice != null ? Number(row.inboundPrice) : undefined,
|
||||
inboundAmount: row.inboundAmount != null ? Number(row.inboundAmount) : undefined,
|
||||
outboundQty: row.outboundQty != null ? Number(row.outboundQty) : undefined,
|
||||
outboundPrice: row.outboundPrice != null ? Number(row.outboundPrice) : undefined,
|
||||
outboundAmount: row.outboundAmount != null ? Number(row.outboundAmount) : undefined,
|
||||
remark: row.remark
|
||||
}
|
||||
}
|
||||
|
||||
/** 查看态装货地址:优先段表 address,回退计划 pickupAddress */
|
||||
export function resolveLoadViewAddress(
|
||||
plan?: { pickupAddress?: string | null } | null,
|
||||
load?: { address?: string | null } | null
|
||||
): string {
|
||||
const fromStop = (load?.address || '').trim()
|
||||
if (fromStop) return fromStop
|
||||
return (plan?.pickupAddress || '').trim()
|
||||
}
|
||||
|
||||
/** 查看态送货地址:优先段表 address,首段可回退计划 destinationAddress */
|
||||
export function resolveDeliveryViewAddress(
|
||||
plan?: { destinationAddress?: string | null } | null,
|
||||
delivery?: { address?: string | null } | null,
|
||||
index = 0
|
||||
): string {
|
||||
const fromStop = (delivery?.address || '').trim()
|
||||
if (fromStop) return fromStop
|
||||
if (index === 0) {
|
||||
return (plan?.destinationAddress || '').trim()
|
||||
}
|
||||
return ''
|
||||
}
|
||||
|
||||
export function mapLoadFromApi(load?: PlanLoad | null): PlanLoadForm {
|
||||
if (!load) return createEmptyLoadForm()
|
||||
const defaults = resolveStopDibangDefaults(load.customerName, 'load')
|
||||
return {
|
||||
customerId: load.customerId || '',
|
||||
customerName: load.customerName || '',
|
||||
address: load.address || '',
|
||||
lng: load.lng != null ? Number(load.lng) : null,
|
||||
lat: load.lat != null ? Number(load.lat) : null,
|
||||
loadTime: (load.loadTime || '').slice(0, 10),
|
||||
contact: load.contact || '',
|
||||
notes: load.notes || '',
|
||||
generateDibang: load.generateDibang ?? defaults.generateDibang,
|
||||
dibangDirection: load.dibangDirection || defaults.dibangDirection,
|
||||
contracts: (load.contracts || []).map((item) => ({
|
||||
contractId: String(item.contractId || ''),
|
||||
contractNo: item.contractNo
|
||||
})),
|
||||
products: (load.products || []).map(mapStopProductFromApi)
|
||||
}
|
||||
}
|
||||
|
||||
export function mapDeliveriesFromApi(
|
||||
deliveries?: PlanDelivery[],
|
||||
loadCustomerName?: string | null
|
||||
): PlanDeliveryForm[] {
|
||||
if (!deliveries?.length) return [createEmptyDeliveryForm(1)]
|
||||
return deliveries.map((row, index) => {
|
||||
const defaults = resolveStopDibangDefaults(loadCustomerName, 'delivery')
|
||||
return {
|
||||
seq: row.seq ?? index + 1,
|
||||
customerId: row.customerId || '',
|
||||
customerName: row.customerName || '',
|
||||
address: row.address || '',
|
||||
lng: row.lng != null ? Number(row.lng) : null,
|
||||
lat: row.lat != null ? Number(row.lat) : null,
|
||||
deliveryTime: (row.deliveryTime || '').slice(0, 10),
|
||||
contact: row.contact || '',
|
||||
notes: row.notes || '',
|
||||
generateDibang: row.generateDibang ?? defaults.generateDibang,
|
||||
dibangDirection: row.dibangDirection || defaults.dibangDirection,
|
||||
contracts: (row.contracts || []).map((item) => ({
|
||||
contractId: String(item.contractId || ''),
|
||||
contractNo: item.contractNo
|
||||
})),
|
||||
products: (row.products || []).map(mapStopProductFromApi)
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
/** 旧数据无 load/deliveries 时从供方/需方字段回填 */
|
||||
export function mapLegacyPlanToStops(plan: Plan): {
|
||||
load: PlanLoadForm
|
||||
deliveries: PlanDeliveryForm[]
|
||||
} {
|
||||
const loadDefaults = resolveStopDibangDefaults(plan.supplierName, 'load')
|
||||
const deliveryDefaults = resolveStopDibangDefaults(plan.supplierName, 'delivery')
|
||||
const stopProducts = createStopProductsFromPlanProducts(
|
||||
(plan.products || []).map((item, index) => ({
|
||||
id: item.id,
|
||||
productId: String(item.productId || index),
|
||||
productNo: item.productNo || '',
|
||||
productName: item.productName || '',
|
||||
model: item.model,
|
||||
unit: item.unit || '吨',
|
||||
quantity: Number(item.quantity ?? item.actualQty ?? 0),
|
||||
packageSpec: item.packageSpec,
|
||||
deliveryMethod: item.deliveryMethod,
|
||||
remark: item.remark
|
||||
}))
|
||||
)
|
||||
return {
|
||||
load: {
|
||||
customerId: plan.supplierId || '',
|
||||
customerName: plan.supplierName || '',
|
||||
address: plan.pickupAddress || '',
|
||||
lng: plan.pickupLng != null ? Number(plan.pickupLng) : null,
|
||||
lat: plan.pickupLat != null ? Number(plan.pickupLat) : null,
|
||||
loadTime: (plan.pickupTime || '').slice(0, 10),
|
||||
contact: plan.pickupContact || '',
|
||||
notes: plan.pickupNotes || '',
|
||||
generateDibang: loadDefaults.generateDibang,
|
||||
dibangDirection: loadDefaults.dibangDirection,
|
||||
contracts: (plan.supplierContracts || []).map((item) => ({
|
||||
contractId: String(item.contractId || ''),
|
||||
contractNo: item.contractNo
|
||||
})),
|
||||
products: stopProducts.length ? stopProducts.map((row) => ({ ...row })) : []
|
||||
},
|
||||
deliveries: [
|
||||
{
|
||||
seq: 1,
|
||||
customerId: plan.customerId || '',
|
||||
customerName: plan.customerName || '',
|
||||
address: plan.destinationAddress || '',
|
||||
lng: plan.destinationLng != null ? Number(plan.destinationLng) : null,
|
||||
lat: plan.destinationLat != null ? Number(plan.destinationLat) : null,
|
||||
deliveryTime: (plan.deliveryTime || '').slice(0, 10),
|
||||
contact: plan.deliveryContact || '',
|
||||
notes: plan.destinationNotes || '',
|
||||
generateDibang: deliveryDefaults.generateDibang,
|
||||
dibangDirection: deliveryDefaults.dibangDirection,
|
||||
contracts: (plan.demanderContracts || []).map((item) => ({
|
||||
contractId: String(item.contractId || ''),
|
||||
contractNo: item.contractNo
|
||||
})),
|
||||
products: stopProducts.length ? stopProducts.map((row) => ({ ...row })) : []
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
|
||||
export function syncLoadProductsFromPlan(
|
||||
load: PlanLoadForm,
|
||||
planProducts: PlanFormProductRow[],
|
||||
preserveQty = true
|
||||
) {
|
||||
load.products = reconcileStopProductsWithPlan(load.products, planProducts, {
|
||||
preserveQty,
|
||||
preserveRemark: preserveQty
|
||||
})
|
||||
}
|
||||
|
||||
export function syncDeliveryProductsFromPlan(
|
||||
delivery: PlanDeliveryForm,
|
||||
planProducts: PlanFormProductRow[],
|
||||
preserveQty = false
|
||||
) {
|
||||
delivery.products = reconcileStopProductsWithPlan(delivery.products, planProducts, {
|
||||
preserveQty,
|
||||
preserveRemark: preserveQty
|
||||
})
|
||||
}
|
||||
|
||||
function matchPrevDeliveryProduct(
|
||||
stopProducts: PlanStopProductFormRow[],
|
||||
loadRow: PlanStopProductFormRow,
|
||||
used: Set<number>
|
||||
): PlanStopProductFormRow | undefined {
|
||||
if (loadRow.planProductId) {
|
||||
const byPlanProductId = stopProducts.findIndex(
|
||||
(row, index) =>
|
||||
!used.has(index) &&
|
||||
row.planProductId &&
|
||||
String(row.planProductId) === String(loadRow.planProductId)
|
||||
)
|
||||
if (byPlanProductId >= 0) {
|
||||
used.add(byPlanProductId)
|
||||
return stopProducts[byPlanProductId]
|
||||
}
|
||||
}
|
||||
const byProductId = stopProducts.findIndex(
|
||||
(row, index) => !used.has(index) && String(row.productId) === String(loadRow.productId)
|
||||
)
|
||||
if (byProductId >= 0) {
|
||||
used.add(byProductId)
|
||||
return stopProducts[byProductId]
|
||||
}
|
||||
return undefined
|
||||
}
|
||||
|
||||
function cloneStopProductSharedFields(
|
||||
loadRow: PlanStopProductFormRow,
|
||||
planQty: number,
|
||||
remark?: string
|
||||
): PlanStopProductFormRow {
|
||||
return {
|
||||
...loadRow,
|
||||
aliasOptions: loadRow.aliasOptions ? [...loadRow.aliasOptions] : undefined,
|
||||
brandOptions: loadRow.brandOptions ? [...loadRow.brandOptions] : undefined,
|
||||
planQty,
|
||||
remark: remark ?? loadRow.remark
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 从装货产品同步到各送货段(产品清单 ⊆ 装货)。
|
||||
* C1:仅 1 个送货段时数量跟装货;≥2 段时保留已有段数量,新增行/新增段默认 0。
|
||||
*/
|
||||
export function syncDeliveriesProductsFromLoad(
|
||||
deliveries: PlanDeliveryForm[],
|
||||
loadProducts: PlanStopProductFormRow[],
|
||||
options?: { forceQtyFromLoad?: boolean }
|
||||
): { deliveries: PlanDeliveryForm[]; needSplitHint: boolean } {
|
||||
const multi = deliveries.length >= 2
|
||||
const forceQty = options?.forceQtyFromLoad === true
|
||||
const next = deliveries.map((delivery) => {
|
||||
const used = new Set<number>()
|
||||
const products = loadProducts.map((loadRow) => {
|
||||
const prev = matchPrevDeliveryProduct(delivery.products || [], loadRow, used)
|
||||
let planQty: number
|
||||
if (forceQty || !multi) {
|
||||
planQty = Number(loadRow.planQty ?? 0)
|
||||
} else if (prev) {
|
||||
planQty = Number(prev.planQty ?? 0)
|
||||
} else {
|
||||
planQty = 0
|
||||
}
|
||||
return cloneStopProductSharedFields(loadRow, planQty, prev?.remark)
|
||||
})
|
||||
return { ...delivery, products }
|
||||
})
|
||||
return { deliveries: next, needSplitHint: multi }
|
||||
}
|
||||
|
||||
/** 装货产品 → 计划层产品行(保存 pl_plan_product / 运费计算) */
|
||||
export function mapLoadProductsToPlanFormRows(
|
||||
loadProducts: PlanStopProductFormRow[]
|
||||
): PlanFormProductRow[] {
|
||||
return loadProducts.map((row) => ({
|
||||
id: row.planProductId,
|
||||
productId: row.productId,
|
||||
productNo: row.productNo,
|
||||
productName: row.productName,
|
||||
standardProductName: row.standardProductName || row.productName,
|
||||
aliasName: row.aliasName,
|
||||
aliasOptions: row.aliasOptions ? [...row.aliasOptions] : undefined,
|
||||
brandMode: row.brandMode,
|
||||
brandId: row.brandId,
|
||||
brandName: row.brandName,
|
||||
brandOptions: row.brandOptions ? [...row.brandOptions] : undefined,
|
||||
model: row.model,
|
||||
unit: row.unit || '吨',
|
||||
quantity: Number(row.planQty ?? 0),
|
||||
actualQty: 0,
|
||||
packageSpec: row.packageSpec,
|
||||
deliveryMethod: row.deliveryMethod,
|
||||
remark: row.remark,
|
||||
isExplosive: row.isExplosive,
|
||||
isToxic: row.isToxic
|
||||
}))
|
||||
}
|
||||
|
||||
/** 合并装货映射行与既有计划产品元数据(危化证、税额等) */
|
||||
export function mergePlanProductsFromLoadMirror(
|
||||
fromLoad: PlanFormProductRow[],
|
||||
previous: PlanFormProductRow[]
|
||||
): PlanFormProductRow[] {
|
||||
return fromLoad.map((row) => {
|
||||
const prev =
|
||||
(row.id && previous.find((item) => item.id && String(item.id) === String(row.id))) ||
|
||||
previous.find((item) => String(item.productId) === String(row.productId))
|
||||
if (!prev) return row
|
||||
return {
|
||||
...row,
|
||||
id: prev.id || row.id,
|
||||
categoryName: row.categoryName || prev.categoryName,
|
||||
standardProductName: row.standardProductName || prev.standardProductName || row.productName,
|
||||
aliasOptions: row.aliasOptions?.length ? row.aliasOptions : prev.aliasOptions,
|
||||
brandOptions: row.brandOptions?.length ? row.brandOptions : prev.brandOptions,
|
||||
taxRate: prev.taxRate,
|
||||
taxPrice: prev.taxPrice ?? row.taxPrice,
|
||||
taxAmount: prev.taxAmount,
|
||||
taxSubtotal: prev.taxSubtotal,
|
||||
purchaseCertUrl: prev.purchaseCertUrl,
|
||||
transportCertUrl: prev.transportCertUrl,
|
||||
legalUseCertUrl: prev.legalUseCertUrl
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
export function buildStopProductPayload(row: PlanStopProductFormRow) {
|
||||
return {
|
||||
planProductId: row.planProductId || undefined,
|
||||
productId: row.productId,
|
||||
productNo: row.productNo,
|
||||
productName: row.productName,
|
||||
model: row.model,
|
||||
unit: row.unit,
|
||||
packageSpec: row.packageSpec,
|
||||
deliveryMethod: row.deliveryMethod,
|
||||
planQty: row.planQty ?? 0,
|
||||
remark: row.remark
|
||||
}
|
||||
}
|
||||
|
||||
export function buildLoadPayload(load: PlanLoadForm) {
|
||||
return {
|
||||
customerId: load.customerId,
|
||||
customerName: load.customerName,
|
||||
address: load.address || undefined,
|
||||
lng: load.lng,
|
||||
lat: load.lat,
|
||||
loadTime: load.loadTime || undefined,
|
||||
contact: load.contact || undefined,
|
||||
notes: load.notes || undefined,
|
||||
generateDibang: load.generateDibang,
|
||||
dibangDirection: load.dibangDirection,
|
||||
contracts: load.contracts,
|
||||
products: load.products.map(buildStopProductPayload)
|
||||
}
|
||||
}
|
||||
|
||||
export function buildDeliveriesPayload(deliveries: PlanDeliveryForm[]) {
|
||||
return deliveries.map((row, index) => ({
|
||||
seq: row.seq || index + 1,
|
||||
customerId: row.customerId,
|
||||
customerName: row.customerName,
|
||||
address: row.address || undefined,
|
||||
lng: row.lng,
|
||||
lat: row.lat,
|
||||
deliveryTime: row.deliveryTime || undefined,
|
||||
contact: row.contact || undefined,
|
||||
notes: row.notes || undefined,
|
||||
generateDibang: row.generateDibang,
|
||||
dibangDirection: row.dibangDirection,
|
||||
contracts: row.contracts,
|
||||
products: row.products.map(buildStopProductPayload)
|
||||
}))
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
import type { Plan, TransportInventoryLink } from '@/api/pl'
|
||||
|
||||
export function formatTransportInventoryLinkLabel(
|
||||
record: TransportInventoryLink,
|
||||
plan?: Plan | null
|
||||
): string {
|
||||
const product = (record.productName || '').trim() || '—'
|
||||
let stopLabel = '地磅单'
|
||||
if (record.stopType === 'load') {
|
||||
stopLabel = '装货'
|
||||
} else if (record.stopType === 'delivery') {
|
||||
const deliveries = plan?.deliveries || []
|
||||
const match = record.stopId
|
||||
? deliveries.find((item) => item.id && String(item.id) === String(record.stopId))
|
||||
: undefined
|
||||
stopLabel = match?.seq ? `送货 #${match.seq}` : '送货'
|
||||
}
|
||||
const batch = (record.batchNo || '').trim()
|
||||
return batch ? `${stopLabel} · ${product} · ${batch}` : `${stopLabel} · ${product}`
|
||||
}
|
||||
@@ -177,6 +177,15 @@
|
||||
>
|
||||
<template #default="{ row }">{{ formatAmount(row.freightAmount) }}</template>
|
||||
</el-table-column>
|
||||
<el-table-column
|
||||
v-if="isColumnVisible('freightRemark')"
|
||||
prop="freightRemark"
|
||||
label="运费备注"
|
||||
min-width="160"
|
||||
show-overflow-tooltip
|
||||
>
|
||||
<template #default="{ row }">{{ row.freightRemark || '—' }}</template>
|
||||
</el-table-column>
|
||||
<el-table-column
|
||||
v-if="isColumnVisible('archiveTime')"
|
||||
prop="archiveTime"
|
||||
@@ -248,6 +257,7 @@ const listColumnDefs = [
|
||||
{ prop: 'licensePlate', label: '车牌号' },
|
||||
{ prop: 'transportCompany', label: '承运商' },
|
||||
{ prop: 'freightAmount', label: '运费(元)' },
|
||||
{ prop: 'freightRemark', label: '运费备注' },
|
||||
{ prop: 'archiveTime', label: '归档时间' }
|
||||
]
|
||||
|
||||
|
||||
@@ -139,260 +139,347 @@
|
||||
|
||||
<div class="list-body list-wrap">
|
||||
<div ref="archiveTableWrapRef" class="table-scroll bx-list-table-wrap">
|
||||
<ListTable table-key="pl-plan-archive"
|
||||
class="list-table"
|
||||
:data="planList"
|
||||
<ListTable
|
||||
table-key="pl-plan-archive"
|
||||
class="list-table pl-plan-merge-list-table"
|
||||
:data="displayRows"
|
||||
v-loading="loading"
|
||||
stripe
|
||||
row-key="id"
|
||||
@selection-change="handleSelectionChange"
|
||||
@row-dblclick="handleView"
|
||||
row-key="rowKey"
|
||||
:span-method="planListSpanMethod"
|
||||
:row-class-name="getPlPlanListRowClassName"
|
||||
@selection-change="handleDisplaySelectionChange"
|
||||
@row-dblclick="handleDisplayRowDblClick"
|
||||
@header-dragend="() => archiveStatsRowRef?.resync?.()"
|
||||
>
|
||||
<el-table-column type="selection" width="55" align="center" header-align="center" />
|
||||
<el-table-column
|
||||
type="index"
|
||||
label="序号"
|
||||
width="68"
|
||||
align="center"
|
||||
header-align="center"
|
||||
:index="(index) => (pagination.page - 1) * pagination.pageSize + index + 1"
|
||||
/>
|
||||
<el-table-column prop="planNo" label="计划编号" min-width="180" show-overflow-tooltip>
|
||||
<template #default="{ row }">
|
||||
<el-link type="primary" @click="handleView(row)">{{ row.planNo }}</el-link>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column
|
||||
v-if="isColumnVisible('planDate')"
|
||||
prop="planDate"
|
||||
label="计划日期"
|
||||
min-width="120"
|
||||
align="center"
|
||||
/>
|
||||
<el-table-column
|
||||
v-if="isColumnVisible('archiveStatus')"
|
||||
prop="archiveStatus"
|
||||
label="归档状态"
|
||||
min-width="100"
|
||||
align="center"
|
||||
>
|
||||
<template #default="{ row }">
|
||||
<el-tag :type="getPlPlanArchiveStatusTagType(row.archiveStatus)" size="small">
|
||||
{{ getPlPlanArchiveStatusLabel(row.archiveStatus) }}
|
||||
</el-tag>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column
|
||||
v-if="isColumnVisible('followStatus')"
|
||||
prop="followStatus"
|
||||
label="跟进状态"
|
||||
min-width="100"
|
||||
align="center"
|
||||
>
|
||||
<template #default="{ row }">
|
||||
<el-tag :type="getPlPlanFollowStatusTagType(row.followStatus)" size="small">
|
||||
{{ getPlPlanFollowStatusLabel(row.followStatus) }}
|
||||
</el-tag>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column
|
||||
v-if="isColumnVisible('planType')"
|
||||
prop="planType"
|
||||
label="单据类型"
|
||||
min-width="100"
|
||||
align="center"
|
||||
>
|
||||
<template #default="{ row }">
|
||||
{{ getPlanTypeLabel(row.planType) }}
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column
|
||||
v-if="isColumnVisible('supplierName')"
|
||||
prop="supplierName"
|
||||
label="供方"
|
||||
min-width="200"
|
||||
align="left"
|
||||
header-align="left"
|
||||
class-name="col-name-wrap"
|
||||
label-class-name="col-name-wrap"
|
||||
show-overflow-tooltip
|
||||
/>
|
||||
<el-table-column
|
||||
v-if="isColumnVisible('customerName')"
|
||||
prop="customerName"
|
||||
label="需方"
|
||||
min-width="200"
|
||||
align="left"
|
||||
header-align="left"
|
||||
class-name="col-name-wrap"
|
||||
label-class-name="col-name-wrap"
|
||||
show-overflow-tooltip
|
||||
/>
|
||||
<el-table-column
|
||||
v-if="isColumnVisible('documentAttachments')"
|
||||
label="单据附件"
|
||||
min-width="220"
|
||||
align="left"
|
||||
header-align="left"
|
||||
>
|
||||
<template #default="{ row }">
|
||||
<PlPlanDocumentAttachmentCell :attachments="row.documentAttachments" />
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column
|
||||
v-if="isColumnVisible('erpEntered')"
|
||||
label="ERP"
|
||||
min-width="72"
|
||||
align="center"
|
||||
header-align="center"
|
||||
>
|
||||
<template #default="{ row }">
|
||||
<div class="pl-plan-archive-erp-cell" @click.stop @mousedown.stop>
|
||||
<el-checkbox
|
||||
class="pl-plan-archive-erp-checkbox"
|
||||
:model-value="Number(row.erpEntered) === 1"
|
||||
<el-table-column
|
||||
type="selection"
|
||||
width="55"
|
||||
align="center"
|
||||
header-align="center"
|
||||
:selectable="isPlanFirstRowSelectable"
|
||||
/>
|
||||
<el-table-column
|
||||
type="index"
|
||||
label="序号"
|
||||
width="68"
|
||||
align="center"
|
||||
header-align="center"
|
||||
:index="getDisplayRowIndex"
|
||||
/>
|
||||
<el-table-column prop="planNo" label="计划编号" min-width="180" show-overflow-tooltip>
|
||||
<template #default="{ row }">
|
||||
<el-link type="primary" @click="handleView(row.plan)">{{
|
||||
row.plan.planNo
|
||||
}}</el-link>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column
|
||||
v-if="isColumnVisible('planDate')"
|
||||
prop="planDate"
|
||||
label="计划日期"
|
||||
min-width="120"
|
||||
align="center"
|
||||
>
|
||||
<template #default="{ row }">{{ row.plan.planDate || '—' }}</template>
|
||||
</el-table-column>
|
||||
<el-table-column
|
||||
v-if="isColumnVisible('archiveStatus')"
|
||||
prop="archiveStatus"
|
||||
label="归档状态"
|
||||
min-width="100"
|
||||
align="center"
|
||||
>
|
||||
<template #default="{ row }">
|
||||
<el-tag :type="getPlPlanArchiveStatusTagType(row.plan.archiveStatus)" size="small">
|
||||
{{ getPlPlanArchiveStatusLabel(row.plan.archiveStatus) }}
|
||||
</el-tag>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column
|
||||
v-if="isColumnVisible('followStatus')"
|
||||
prop="followStatus"
|
||||
label="跟进状态"
|
||||
min-width="100"
|
||||
align="center"
|
||||
>
|
||||
<template #default="{ row }">
|
||||
<el-tag :type="getPlPlanFollowStatusTagType(row.plan.followStatus)" size="small">
|
||||
{{ getPlPlanFollowStatusLabel(row.plan.followStatus) }}
|
||||
</el-tag>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column
|
||||
v-if="isColumnVisible('planType')"
|
||||
prop="planType"
|
||||
label="单据类型"
|
||||
min-width="100"
|
||||
align="center"
|
||||
>
|
||||
<template #default="{ row }">
|
||||
{{ getPlanTypeLabel(row.plan.planType) }}
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column
|
||||
v-if="isColumnVisible('documentAttachments')"
|
||||
label="单据附件"
|
||||
min-width="220"
|
||||
align="left"
|
||||
header-align="left"
|
||||
>
|
||||
<template #default="{ row }">
|
||||
<PlPlanDocumentAttachmentCell
|
||||
:attachments="row.plan.documentAttachments"
|
||||
use-placeholder-thumb
|
||||
/>
|
||||
</div>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column
|
||||
v-if="isColumnVisible('productName')"
|
||||
label="产品名称"
|
||||
min-width="160"
|
||||
align="left"
|
||||
header-align="left"
|
||||
class-name="col-name-wrap"
|
||||
label-class-name="col-name-wrap"
|
||||
>
|
||||
<template #default="{ row }">
|
||||
<PlPlanListProductCell :products="row.products" field="name" />
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column
|
||||
v-if="isColumnVisible('productSpec')"
|
||||
label="型号/规格"
|
||||
min-width="96"
|
||||
align="center"
|
||||
header-align="center"
|
||||
show-overflow-tooltip
|
||||
>
|
||||
<template #default="{ row }">
|
||||
<PlPlanListProductCell :products="row.products" field="spec" />
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column
|
||||
v-if="isColumnVisible('productUnit')"
|
||||
label="单位"
|
||||
min-width="64"
|
||||
align="center"
|
||||
header-align="center"
|
||||
>
|
||||
<template #default="{ row }">
|
||||
<PlPlanListProductCell :products="row.products" field="unit" />
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column
|
||||
v-if="isColumnVisible('productPlanQty')"
|
||||
label="计划数量"
|
||||
min-width="100"
|
||||
align="right"
|
||||
header-align="right"
|
||||
>
|
||||
<template #default="{ row }">
|
||||
<PlPlanListProductCell :products="row.products" field="planQty" />
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column
|
||||
v-if="isColumnVisible('productActualQty')"
|
||||
label="实际数量"
|
||||
min-width="100"
|
||||
align="right"
|
||||
header-align="right"
|
||||
>
|
||||
<template #default="{ row }">
|
||||
<PlPlanListProductCell :products="row.products" field="actualQty" />
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column
|
||||
v-if="isColumnVisible('productInboundQty')"
|
||||
label="入库数量"
|
||||
min-width="100"
|
||||
align="right"
|
||||
header-align="right"
|
||||
>
|
||||
<template #default="{ row }">
|
||||
<PlPlanListProductCell :products="row.products" field="inboundQty" />
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column
|
||||
v-if="isColumnVisible('productOutboundQty')"
|
||||
label="出库数量"
|
||||
min-width="100"
|
||||
align="right"
|
||||
header-align="right"
|
||||
>
|
||||
<template #default="{ row }">
|
||||
<PlPlanListProductCell :products="row.products" field="outboundQty" />
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column v-if="isColumnVisible('planAttachments')" label="计划附件" min-width="200">
|
||||
<template #default="{ row }">
|
||||
<PlPlanListCertCell :products="row.products" compact hide-product />
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column
|
||||
v-if="isColumnVisible('licensePlate')"
|
||||
prop="licensePlate"
|
||||
label="车牌号"
|
||||
min-width="160"
|
||||
show-overflow-tooltip
|
||||
align="center"
|
||||
>
|
||||
<template #default="{ row }">
|
||||
{{ formatPlVehiclePlateDisplay(row.licensePlate, row.trailerNo) }}
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column
|
||||
v-if="isColumnVisible('carrierName')"
|
||||
prop="carrierName"
|
||||
label="承运商"
|
||||
min-width="140"
|
||||
show-overflow-tooltip
|
||||
align="left"
|
||||
header-align="left"
|
||||
class-name="col-name-wrap"
|
||||
label-class-name="col-name-wrap"
|
||||
>
|
||||
<template #default="{ row }">
|
||||
{{ row.resourceSnapshot?.carrierName || '' }}
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column
|
||||
v-if="isColumnVisible('personnelSummary')"
|
||||
prop="personnelSummary"
|
||||
label="人员"
|
||||
min-width="180"
|
||||
show-overflow-tooltip
|
||||
align="center"
|
||||
>
|
||||
<template #default="{ row }">
|
||||
{{ normalizePlPersonnelSummaryDisplay(row.personnelSummary) }}
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column
|
||||
v-if="isColumnVisible('followUserName')"
|
||||
prop="followUserName"
|
||||
label="跟进人"
|
||||
min-width="100"
|
||||
align="center"
|
||||
/>
|
||||
</ListTable>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column
|
||||
v-if="isColumnVisible('erpEntered')"
|
||||
label="ERP"
|
||||
min-width="72"
|
||||
align="center"
|
||||
header-align="center"
|
||||
>
|
||||
<template #default="{ row }">
|
||||
<div class="pl-plan-archive-erp-cell" @click.stop @mousedown.stop>
|
||||
<el-checkbox
|
||||
class="pl-plan-archive-erp-checkbox"
|
||||
:model-value="Number(row.plan.erpEntered) === 1"
|
||||
/>
|
||||
</div>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column
|
||||
v-if="isColumnVisible('planAttachments')"
|
||||
label="计划附件"
|
||||
min-width="200"
|
||||
>
|
||||
<template #default="{ row }">
|
||||
<PlPlanListCertCell :products="row.plan.products" compact hide-product />
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column
|
||||
v-if="isColumnVisible('licensePlate')"
|
||||
prop="licensePlate"
|
||||
label="车牌号"
|
||||
min-width="160"
|
||||
show-overflow-tooltip
|
||||
align="center"
|
||||
>
|
||||
<template #default="{ row }">
|
||||
{{
|
||||
formatPlVehiclePlateDisplay(row.plan.licensePlate, row.plan.trailerNo)
|
||||
}}
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column
|
||||
v-if="isColumnVisible('carrierName')"
|
||||
prop="carrierName"
|
||||
label="承运商"
|
||||
min-width="140"
|
||||
show-overflow-tooltip
|
||||
align="left"
|
||||
header-align="left"
|
||||
class-name="col-name-wrap"
|
||||
label-class-name="col-name-wrap"
|
||||
>
|
||||
<template #default="{ row }">
|
||||
{{ row.plan.resourceSnapshot?.carrierName || '' }}
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column
|
||||
v-if="isColumnVisible('personnelSummary')"
|
||||
prop="personnelSummary"
|
||||
label="人员"
|
||||
min-width="180"
|
||||
show-overflow-tooltip
|
||||
align="center"
|
||||
>
|
||||
<template #default="{ row }">
|
||||
{{ normalizePlPersonnelSummaryDisplay(row.plan.personnelSummary) }}
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column
|
||||
v-if="isColumnVisible('followUserName')"
|
||||
prop="followUserName"
|
||||
label="跟进人"
|
||||
min-width="100"
|
||||
align="center"
|
||||
>
|
||||
<template #default="{ row }">{{ row.plan.followUserName || '—' }}</template>
|
||||
</el-table-column>
|
||||
<el-table-column
|
||||
v-if="isColumnVisible('stopKind')"
|
||||
prop="stopKind"
|
||||
label="段次"
|
||||
min-width="88"
|
||||
align="center"
|
||||
class-name="pl-plan-stop-col"
|
||||
>
|
||||
<template #default="{ row }">
|
||||
<span class="pl-plan-stop-kind-text">{{ getStopKindLabel(row) }}</span>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column
|
||||
v-if="isColumnVisible('stopCustomer')"
|
||||
prop="stopCustomer"
|
||||
label="客户"
|
||||
min-width="200"
|
||||
align="left"
|
||||
header-align="left"
|
||||
class-name="col-name-wrap pl-plan-stop-col"
|
||||
label-class-name="col-name-wrap"
|
||||
show-overflow-tooltip
|
||||
>
|
||||
<template #default="{ row }">
|
||||
<span>{{ getStopCustomerName(row) }}</span>
|
||||
<el-tag
|
||||
v-if="isPlInternalCustomerName(getStopCustomerName(row))"
|
||||
type="success"
|
||||
size="small"
|
||||
class="pl-plan-internal-customer-tag"
|
||||
>
|
||||
内部
|
||||
</el-tag>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column
|
||||
v-if="isColumnVisible('stopAddressTime')"
|
||||
prop="stopAddressTime"
|
||||
label="地址 / 时间"
|
||||
min-width="220"
|
||||
align="left"
|
||||
header-align="left"
|
||||
class-name="col-name-wrap pl-plan-stop-col"
|
||||
label-class-name="col-name-wrap"
|
||||
>
|
||||
<template #default="{ row }">
|
||||
<div class="pl-plan-stop-address-time">
|
||||
<div class="pl-plan-stop-address-time__addr">{{ getStopAddress(row) }}</div>
|
||||
<div class="pl-plan-stop-address-time__time">{{ getStopTime(row) }}</div>
|
||||
</div>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column
|
||||
v-if="isColumnVisible('productName')"
|
||||
label="产品名称"
|
||||
min-width="160"
|
||||
align="left"
|
||||
header-align="left"
|
||||
class-name="col-name-wrap pl-plan-stop-col"
|
||||
label-class-name="col-name-wrap"
|
||||
>
|
||||
<template #default="{ row }">
|
||||
<PlPlanListProductCell
|
||||
:stop-products="getStopProducts(row)"
|
||||
:plan-products="row.plan.products"
|
||||
field="name"
|
||||
/>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column
|
||||
v-if="isColumnVisible('productSpec')"
|
||||
label="型号/规格"
|
||||
min-width="96"
|
||||
align="center"
|
||||
header-align="center"
|
||||
class-name="pl-plan-stop-col"
|
||||
show-overflow-tooltip
|
||||
>
|
||||
<template #default="{ row }">
|
||||
<PlPlanListProductCell
|
||||
:stop-products="getStopProducts(row)"
|
||||
:plan-products="row.plan.products"
|
||||
field="spec"
|
||||
/>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column
|
||||
v-if="isColumnVisible('productUnit')"
|
||||
label="单位"
|
||||
min-width="64"
|
||||
align="center"
|
||||
header-align="center"
|
||||
class-name="pl-plan-stop-col"
|
||||
>
|
||||
<template #default="{ row }">
|
||||
<PlPlanListProductCell
|
||||
:stop-products="getStopProducts(row)"
|
||||
:plan-products="row.plan.products"
|
||||
field="unit"
|
||||
/>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column
|
||||
v-if="isColumnVisible('productPlanQty')"
|
||||
label="计划数量"
|
||||
min-width="100"
|
||||
align="right"
|
||||
header-align="right"
|
||||
class-name="pl-plan-stop-col"
|
||||
>
|
||||
<template #default="{ row }">
|
||||
<PlPlanListProductCell
|
||||
:stop-products="getStopProducts(row)"
|
||||
:plan-products="row.plan.products"
|
||||
field="planQty"
|
||||
/>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column
|
||||
v-if="isColumnVisible('productActualQty')"
|
||||
label="实际数量"
|
||||
min-width="100"
|
||||
align="right"
|
||||
header-align="right"
|
||||
class-name="pl-plan-stop-col"
|
||||
>
|
||||
<template #default="{ row }">
|
||||
<PlPlanListProductCell
|
||||
:stop-products="getStopProducts(row)"
|
||||
:plan-products="row.plan.products"
|
||||
field="actualQty"
|
||||
/>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column
|
||||
v-if="isColumnVisible('productInboundQty')"
|
||||
label="入库数量"
|
||||
min-width="100"
|
||||
align="right"
|
||||
header-align="right"
|
||||
class-name="pl-plan-stop-col"
|
||||
>
|
||||
<template #default="{ row }">
|
||||
<PlPlanListProductCell
|
||||
:stop-products="getStopProducts(row)"
|
||||
:plan-products="row.plan.products"
|
||||
field="inboundQty"
|
||||
/>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column
|
||||
v-if="isColumnVisible('productOutboundQty')"
|
||||
label="出库数量"
|
||||
min-width="100"
|
||||
align="right"
|
||||
header-align="right"
|
||||
class-name="pl-plan-stop-col"
|
||||
>
|
||||
<template #default="{ row }">
|
||||
<PlPlanListProductCell
|
||||
:stop-products="getStopProducts(row)"
|
||||
:plan-products="row.plan.products"
|
||||
field="outboundQty"
|
||||
/>
|
||||
</template>
|
||||
</el-table-column>
|
||||
</ListTable>
|
||||
<ListColumnStatsRow
|
||||
ref="archiveStatsRowRef"
|
||||
storage-key="pl-plan-archive-column-stats"
|
||||
:columns="archiveStatsRowColumns"
|
||||
:data="planList"
|
||||
:data="displayRows"
|
||||
:table-wrap-el="archiveTableWrapRef"
|
||||
:get-cell-value="getArchiveStatCellValue"
|
||||
/>
|
||||
@@ -449,6 +536,7 @@ import ListExportDropdown from '@/components/business/list-export-dropdown/index
|
||||
import ListColumnStatsRow from '@/components/business/list-column-stats-row/index.vue'
|
||||
import type { StatsRowColumn } from '@/utils/list-column-stats'
|
||||
import { usePersistedListColumns } from '@/composables/usePersistedListColumns'
|
||||
import { usePlPlanMergeListTable } from '@/composables/usePlPlanMergeListTable'
|
||||
import {
|
||||
ArrowDown,
|
||||
DocumentChecked,
|
||||
@@ -483,10 +571,38 @@ import {
|
||||
type PlPlanTypeTab
|
||||
} from '@/utils/pl-display'
|
||||
import { syncViewRowFromFlatList } from '@/utils/view-dialog-refresh'
|
||||
import {
|
||||
getPlPlanListRowClassName,
|
||||
getStopAddress,
|
||||
getStopCustomerName,
|
||||
getStopKindLabel,
|
||||
getStopProducts,
|
||||
getStopTime,
|
||||
sumStopActualQty,
|
||||
sumStopProductsField,
|
||||
type PlPlanListDisplayRow
|
||||
} from '@/utils/pl-plan-list-display-rows'
|
||||
import { isPlInternalCustomerName } from '@/utils/pl-internal-customer'
|
||||
import { refreshMenuBadges } from '@/utils/menu-badge-registry'
|
||||
import { useMenuStore } from '@/store/modules/menu'
|
||||
|
||||
const menuStore = useMenuStore()
|
||||
|
||||
/** 计划区可合并列(顺序须与表格左侧列一致,不含勾选/序号/计划编号) */
|
||||
const PLAN_MERGE_COLUMN_PROPS = [
|
||||
'planDate',
|
||||
'archiveStatus',
|
||||
'followStatus',
|
||||
'planType',
|
||||
'documentAttachments',
|
||||
'erpEntered',
|
||||
'planAttachments',
|
||||
'licensePlate',
|
||||
'carrierName',
|
||||
'personnelSummary',
|
||||
'followUserName'
|
||||
] as const
|
||||
|
||||
const loading = ref(false)
|
||||
const viewVisible = ref(false)
|
||||
const viewPlanId = ref('')
|
||||
@@ -501,22 +617,23 @@ const listColumnDefs = [
|
||||
{ prop: 'archiveStatus', label: '归档状态' },
|
||||
{ prop: 'followStatus', label: '跟进状态' },
|
||||
{ prop: 'planType', label: '单据类型' },
|
||||
{ prop: 'supplierName', label: '供方' },
|
||||
{ prop: 'customerName', label: '需方' },
|
||||
{ prop: 'documentAttachments', label: '单据附件' },
|
||||
{ prop: 'erpEntered', label: 'ERP' },
|
||||
{ prop: 'planAttachments', label: '计划附件' },
|
||||
{ prop: 'licensePlate', label: '车牌号' },
|
||||
{ prop: 'carrierName', label: '承运商' },
|
||||
{ prop: 'personnelSummary', label: '人员' },
|
||||
{ prop: 'followUserName', label: '跟进人', defaultVisible: false },
|
||||
{ prop: 'stopKind', label: '段次' },
|
||||
{ prop: 'stopCustomer', label: '客户' },
|
||||
{ prop: 'stopAddressTime', label: '地址 / 时间' },
|
||||
{ prop: 'productName', label: '产品名称' },
|
||||
{ prop: 'productSpec', label: '型号/规格' },
|
||||
{ prop: 'productUnit', label: '单位' },
|
||||
{ prop: 'productPlanQty', label: '计划数量' },
|
||||
{ prop: 'productActualQty', label: '实际数量' },
|
||||
{ prop: 'productInboundQty', label: '入库数量' },
|
||||
{ prop: 'productOutboundQty', label: '出库数量' },
|
||||
{ prop: 'planAttachments', label: '计划附件' },
|
||||
{ prop: 'licensePlate', label: '车牌号' },
|
||||
{ prop: 'carrierName', label: '承运商' },
|
||||
{ prop: 'personnelSummary', label: '人员' },
|
||||
{ prop: 'followUserName', label: '跟进人', defaultVisible: false }
|
||||
{ prop: 'productOutboundQty', label: '出库数量' }
|
||||
]
|
||||
|
||||
const {
|
||||
@@ -525,9 +642,34 @@ const {
|
||||
isIndeterminate,
|
||||
isColumnVisible,
|
||||
resetToDefault
|
||||
} = usePersistedListColumns('pl-plan-archive-list-columns', listColumnDefs)
|
||||
} = usePersistedListColumns('pl-plan-archive-list-columns-v3', listColumnDefs)
|
||||
|
||||
const archiveTableWrapRef = ref<HTMLElement | null>(null)
|
||||
const selectedRows = ref<Plan[]>([])
|
||||
|
||||
const pagination = reactive({
|
||||
page: 1,
|
||||
pageSize: 20,
|
||||
total: 0
|
||||
})
|
||||
|
||||
const visiblePlanMergeProps = computed(() =>
|
||||
PLAN_MERGE_COLUMN_PROPS.filter((prop) => isColumnVisible(prop))
|
||||
)
|
||||
|
||||
const {
|
||||
displayRows,
|
||||
planListSpanMethod,
|
||||
getDisplayRowIndex,
|
||||
isPlanFirstRowSelectable,
|
||||
handleDisplaySelectionChange,
|
||||
handleDisplayRowDblClick
|
||||
} = usePlPlanMergeListTable({
|
||||
planList,
|
||||
visiblePlanMergeProps,
|
||||
selectedRows,
|
||||
pagination,
|
||||
onView: (plan) => handleView(plan)
|
||||
})
|
||||
const archiveStatsRowRef = ref<{ resync?: () => void } | null>(null)
|
||||
|
||||
const archiveStatsRowColumns = computed((): StatsRowColumn[] => {
|
||||
@@ -540,63 +682,63 @@ const archiveStatsRowColumns = computed((): StatsRowColumn[] => {
|
||||
if (!isColumnVisible(def.prop)) continue
|
||||
cols.push({
|
||||
key: def.prop,
|
||||
interactive: true,
|
||||
interactive: def.prop !== 'stopKind',
|
||||
prop: def.prop
|
||||
})
|
||||
}
|
||||
return cols
|
||||
})
|
||||
|
||||
function getArchiveStatCellValue(row: Plan, prop: string): unknown {
|
||||
if (prop === 'archiveStatus') return getPlPlanArchiveStatusLabel(row.archiveStatus)
|
||||
if (prop === 'followStatus') return getPlPlanFollowStatusLabel(row.followStatus)
|
||||
if (prop === 'planType') return getPlanTypeLabel(row.planType)
|
||||
if (prop === 'productPlanQty') {
|
||||
return (row.products || []).reduce((sum, p) => sum + (Number(p.quantity) || 0), 0)
|
||||
}
|
||||
if (prop === 'productActualQty') {
|
||||
return (row.products || []).reduce((sum, p) => sum + (Number(p.actualQty) || 0), 0)
|
||||
}
|
||||
if (prop === 'productInboundQty') {
|
||||
return (row.products || []).reduce((sum, p) => sum + (Number(p.inboundQty) || 0), 0)
|
||||
}
|
||||
if (prop === 'productOutboundQty') {
|
||||
return (row.products || []).reduce((sum, p) => sum + (Number(p.outboundQty) || 0), 0)
|
||||
function getArchiveStatCellValue(row: PlPlanListDisplayRow, prop: string): unknown {
|
||||
const plan = row.plan
|
||||
const stopProducts = getStopProducts(row)
|
||||
if (prop === 'planNo') return plan.planNo
|
||||
if (prop === 'archiveStatus') return getPlPlanArchiveStatusLabel(plan.archiveStatus)
|
||||
if (prop === 'followStatus') return getPlPlanFollowStatusLabel(plan.followStatus)
|
||||
if (prop === 'planType') return getPlanTypeLabel(plan.planType)
|
||||
if (prop === 'stopKind') return getStopKindLabel(row)
|
||||
if (prop === 'stopCustomer') return getStopCustomerName(row)
|
||||
if (prop === 'stopAddressTime') {
|
||||
return `${getStopAddress(row)} ${getStopTime(row)}`.trim()
|
||||
}
|
||||
if (prop === 'productPlanQty') return sumStopProductsField(stopProducts, 'planQty')
|
||||
if (prop === 'productActualQty') return sumStopActualQty(plan, stopProducts)
|
||||
if (prop === 'productInboundQty') return sumStopProductsField(stopProducts, 'inboundQty')
|
||||
if (prop === 'productOutboundQty') return sumStopProductsField(stopProducts, 'outboundQty')
|
||||
if (prop === 'productName') {
|
||||
return (row.products || []).map((p) => p.productName || '').filter(Boolean).join('\n')
|
||||
return stopProducts
|
||||
.map((p) => p.productName || '')
|
||||
.filter(Boolean)
|
||||
.join('\n')
|
||||
}
|
||||
if (prop === 'productSpec') {
|
||||
return (row.products || [])
|
||||
return stopProducts
|
||||
.map((p) => p.model || p.packageSpec || '')
|
||||
.filter(Boolean)
|
||||
.join('\n')
|
||||
}
|
||||
if (prop === 'productUnit') {
|
||||
return (row.products || []).map((p) => p.unit || '').filter(Boolean).join('\n')
|
||||
}
|
||||
if (prop === 'planAttachments') {
|
||||
return ''
|
||||
}
|
||||
if (prop === 'documentAttachments') {
|
||||
return ''
|
||||
}
|
||||
if (prop === 'erpEntered') {
|
||||
return Number(row.erpEntered) === 1 ? '是' : '否'
|
||||
return stopProducts
|
||||
.map((p) => p.unit || '')
|
||||
.filter(Boolean)
|
||||
.join('\n')
|
||||
}
|
||||
if (prop === 'planAttachments' || prop === 'documentAttachments') return ''
|
||||
if (prop === 'erpEntered') return Number(plan.erpEntered) === 1 ? '是' : '否'
|
||||
if (prop === 'licensePlate') {
|
||||
return formatPlVehiclePlateDisplay(row.licensePlate, row.trailerNo)
|
||||
}
|
||||
if (prop === 'carrierName') {
|
||||
return row.resourceSnapshot?.carrierName || ''
|
||||
return formatPlVehiclePlateDisplay(plan.licensePlate, plan.trailerNo)
|
||||
}
|
||||
if (prop === 'carrierName') return plan.resourceSnapshot?.carrierName || ''
|
||||
if (prop === 'personnelSummary') {
|
||||
return normalizePlPersonnelSummaryDisplay(row.personnelSummary)
|
||||
return normalizePlPersonnelSummaryDisplay(plan.personnelSummary)
|
||||
}
|
||||
return (row as any)?.[prop]
|
||||
if (prop === 'followUserName') return plan.followUserName
|
||||
if (prop === 'planDate') return plan.planDate
|
||||
return ''
|
||||
}
|
||||
|
||||
const selectedRows = ref<Plan[]>([])
|
||||
const archiveTableWrapRef = ref<HTMLElement | null>(null)
|
||||
|
||||
function getPlanArchiveExportFilterParams() {
|
||||
const keyword = quickSearch.value.trim()
|
||||
return {
|
||||
@@ -645,12 +787,6 @@ const searchForm = reactive({
|
||||
archiveStatus: ''
|
||||
})
|
||||
|
||||
const pagination = reactive({
|
||||
page: 1,
|
||||
pageSize: 20,
|
||||
total: 0
|
||||
})
|
||||
|
||||
function getPlanTypeLabel(type: string) {
|
||||
const map: Record<string, string> = { direct: '直销单', inbound: '入库单', outbound: '出库单' }
|
||||
return map[type] || type
|
||||
@@ -726,10 +862,6 @@ const { activeDateShortcut, handleDateShortcut, resetDateShortcut } = useListDat
|
||||
handleSearch
|
||||
)
|
||||
|
||||
function handleSelectionChange(selection: Plan[]) {
|
||||
selectedRows.value = selection
|
||||
}
|
||||
|
||||
function handlePageChange() {
|
||||
fetchData()
|
||||
}
|
||||
@@ -854,6 +986,8 @@ onMounted(() => {
|
||||
</script>
|
||||
|
||||
<style scoped lang="scss">
|
||||
@use '@styles/business/pl-plan-merge-list-table.scss';
|
||||
|
||||
.bx-list-table-wrap {
|
||||
min-width: 0;
|
||||
}
|
||||
|
||||
@@ -158,27 +158,35 @@
|
||||
|
||||
<!-- 数据表格 -->
|
||||
<div class="list-body list-wrap">
|
||||
<ListTable table-key="pl-plan-cert"
|
||||
class="list-table"
|
||||
:data="planList"
|
||||
<ListTable
|
||||
table-key="pl-plan-cert"
|
||||
class="list-table pl-plan-merge-list-table"
|
||||
:data="displayRows"
|
||||
v-loading="loading"
|
||||
stripe
|
||||
row-key="id"
|
||||
@selection-change="handleSelectionChange"
|
||||
@row-dblclick="handleView"
|
||||
row-key="rowKey"
|
||||
:span-method="planListSpanMethod"
|
||||
:row-class-name="getPlPlanListRowClassName"
|
||||
@selection-change="handleDisplaySelectionChange"
|
||||
@row-dblclick="handleDisplayRowDblClick"
|
||||
>
|
||||
<el-table-column type="selection" width="55" align="center" header-align="center" />
|
||||
<el-table-column
|
||||
type="selection"
|
||||
width="55"
|
||||
align="center"
|
||||
header-align="center"
|
||||
:selectable="isPlanFirstRowSelectable"
|
||||
/>
|
||||
<el-table-column
|
||||
type="index"
|
||||
label="序号"
|
||||
width="68"
|
||||
align="center"
|
||||
header-align="center"
|
||||
:index="(index) => (pagination.page - 1) * pagination.pageSize + index + 1"
|
||||
:index="getDisplayRowIndex"
|
||||
/>
|
||||
<el-table-column prop="planNo" label="计划编号" min-width="150" show-overflow-tooltip>
|
||||
<template #default="{ row }">
|
||||
<el-link type="primary" @click="handleView(row)">{{ row.planNo }}</el-link>
|
||||
<el-link type="primary" @click="handleView(row.plan)">{{ row.plan.planNo }}</el-link>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column
|
||||
@@ -187,29 +195,9 @@
|
||||
label="计划日期"
|
||||
min-width="120"
|
||||
align="center"
|
||||
/>
|
||||
<el-table-column
|
||||
v-if="isColumnVisible('supplierName')"
|
||||
prop="supplierName"
|
||||
label="供方"
|
||||
min-width="200"
|
||||
align="left"
|
||||
header-align="left"
|
||||
class-name="col-name-wrap"
|
||||
label-class-name="col-name-wrap"
|
||||
show-overflow-tooltip
|
||||
/>
|
||||
<el-table-column
|
||||
v-if="isColumnVisible('customerName')"
|
||||
prop="customerName"
|
||||
label="需方"
|
||||
min-width="200"
|
||||
align="left"
|
||||
header-align="left"
|
||||
class-name="col-name-wrap"
|
||||
label-class-name="col-name-wrap"
|
||||
show-overflow-tooltip
|
||||
/>
|
||||
>
|
||||
<template #default="{ row }">{{ row.plan.planDate || '—' }}</template>
|
||||
</el-table-column>
|
||||
<el-table-column
|
||||
v-if="isColumnVisible('planType')"
|
||||
prop="planType"
|
||||
@@ -218,7 +206,7 @@
|
||||
align="center"
|
||||
>
|
||||
<template #default="{ row }">
|
||||
{{ getPlanTypeLabel(row.planType) }}
|
||||
{{ getPlanTypeLabel(row.plan.planType) }}
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column
|
||||
@@ -229,8 +217,8 @@
|
||||
align="center"
|
||||
>
|
||||
<template #default="{ row }">
|
||||
<el-tag :type="getPlPlanFollowStatusTagType(row.followStatus)" size="small">
|
||||
{{ getPlPlanFollowStatusLabel(row.followStatus) }}
|
||||
<el-tag :type="getPlPlanFollowStatusTagType(row.plan.followStatus)" size="small">
|
||||
{{ getPlPlanFollowStatusLabel(row.plan.followStatus) }}
|
||||
</el-tag>
|
||||
</template>
|
||||
</el-table-column>
|
||||
@@ -241,100 +229,24 @@
|
||||
align="center"
|
||||
>
|
||||
<template #default="{ row }">
|
||||
<el-tag :type="getHazardCertReadyTagType(row)" size="small">
|
||||
{{ getHazardCertReadyLabel(row) }}
|
||||
<el-tag :type="getHazardCertReadyTagType(row.plan)" size="small">
|
||||
{{ getHazardCertReadyLabel(row.plan) }}
|
||||
</el-tag>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column
|
||||
v-if="isColumnVisible('productName')"
|
||||
label="产品名称"
|
||||
min-width="160"
|
||||
align="left"
|
||||
header-align="left"
|
||||
class-name="col-name-wrap"
|
||||
label-class-name="col-name-wrap"
|
||||
v-if="isColumnVisible('planAttachments')"
|
||||
label="计划附件"
|
||||
min-width="280"
|
||||
>
|
||||
<template #default="{ row }">
|
||||
<PlPlanListProductCell :products="row.products" field="name" />
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column
|
||||
v-if="isColumnVisible('productSpec')"
|
||||
label="型号/规格"
|
||||
min-width="96"
|
||||
align="center"
|
||||
header-align="center"
|
||||
show-overflow-tooltip
|
||||
>
|
||||
<template #default="{ row }">
|
||||
<PlPlanListProductCell :products="row.products" field="spec" />
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column
|
||||
v-if="isColumnVisible('productUnit')"
|
||||
label="单位"
|
||||
min-width="64"
|
||||
align="center"
|
||||
header-align="center"
|
||||
>
|
||||
<template #default="{ row }">
|
||||
<PlPlanListProductCell :products="row.products" field="unit" />
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column
|
||||
v-if="isColumnVisible('productPlanQty')"
|
||||
label="计划数量"
|
||||
min-width="88"
|
||||
align="right"
|
||||
header-align="right"
|
||||
>
|
||||
<template #default="{ row }">
|
||||
<PlPlanListProductCell :products="row.products" field="planQty" />
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column
|
||||
v-if="isColumnVisible('productActualQty')"
|
||||
label="实际数量"
|
||||
min-width="88"
|
||||
align="right"
|
||||
header-align="right"
|
||||
>
|
||||
<template #default="{ row }">
|
||||
<PlPlanListProductCell :products="row.products" field="actualQty" />
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column
|
||||
v-if="isColumnVisible('productInboundQty')"
|
||||
label="入库数量"
|
||||
min-width="88"
|
||||
align="right"
|
||||
header-align="right"
|
||||
>
|
||||
<template #default="{ row }">
|
||||
<PlPlanListProductCell :products="row.products" field="inboundQty" />
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column
|
||||
v-if="isColumnVisible('productOutboundQty')"
|
||||
label="出库数量"
|
||||
min-width="88"
|
||||
align="right"
|
||||
header-align="right"
|
||||
>
|
||||
<template #default="{ row }">
|
||||
<PlPlanListProductCell :products="row.products" field="outboundQty" />
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column v-if="isColumnVisible('planAttachments')" label="计划附件" min-width="280">
|
||||
<template #default="{ row }">
|
||||
<PlPlanListCertCell
|
||||
:products="row.products"
|
||||
:products="row.plan.products"
|
||||
hide-product
|
||||
clickable
|
||||
:clickable-disabled="!canUploadCert(row)"
|
||||
:clickable-disabled="!canUploadCert(row.plan)"
|
||||
:media-active="mediaActive"
|
||||
@click="handleUploadCert(row)"
|
||||
@click="handleUploadCert(row.plan)"
|
||||
/>
|
||||
</template>
|
||||
</el-table-column>
|
||||
@@ -347,7 +259,7 @@
|
||||
align="center"
|
||||
>
|
||||
<template #default="{ row }">
|
||||
{{ formatPlVehiclePlateDisplay(row.licensePlate, row.trailerNo) }}
|
||||
{{ formatPlVehiclePlateDisplay(row.plan.licensePlate, row.plan.trailerNo) }}
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column
|
||||
@@ -359,7 +271,7 @@
|
||||
align="center"
|
||||
>
|
||||
<template #default="{ row }">
|
||||
{{ normalizePlPersonnelSummaryDisplay(row.personnelSummary) }}
|
||||
{{ normalizePlPersonnelSummaryDisplay(row.plan.personnelSummary) }}
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column
|
||||
@@ -368,7 +280,175 @@
|
||||
label="跟进人"
|
||||
min-width="100"
|
||||
align="center"
|
||||
/>
|
||||
>
|
||||
<template #default="{ row }">{{ row.plan.followUserName || '—' }}</template>
|
||||
</el-table-column>
|
||||
<el-table-column
|
||||
v-if="isColumnVisible('stopKind')"
|
||||
prop="stopKind"
|
||||
label="段次"
|
||||
min-width="88"
|
||||
align="center"
|
||||
class-name="pl-plan-stop-col"
|
||||
>
|
||||
<template #default="{ row }">
|
||||
<span class="pl-plan-stop-kind-text">{{ getStopKindLabel(row) }}</span>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column
|
||||
v-if="isColumnVisible('stopCustomer')"
|
||||
prop="stopCustomer"
|
||||
label="客户"
|
||||
min-width="200"
|
||||
align="left"
|
||||
header-align="left"
|
||||
class-name="col-name-wrap pl-plan-stop-col"
|
||||
label-class-name="col-name-wrap"
|
||||
show-overflow-tooltip
|
||||
>
|
||||
<template #default="{ row }">
|
||||
<span>{{ getStopCustomerName(row) }}</span>
|
||||
<el-tag
|
||||
v-if="isPlInternalCustomerName(getStopCustomerName(row))"
|
||||
type="success"
|
||||
size="small"
|
||||
class="pl-plan-internal-customer-tag"
|
||||
>
|
||||
内部
|
||||
</el-tag>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column
|
||||
v-if="isColumnVisible('stopAddressTime')"
|
||||
prop="stopAddressTime"
|
||||
label="地址 / 时间"
|
||||
min-width="220"
|
||||
align="left"
|
||||
header-align="left"
|
||||
class-name="col-name-wrap pl-plan-stop-col"
|
||||
label-class-name="col-name-wrap"
|
||||
>
|
||||
<template #default="{ row }">
|
||||
<div class="pl-plan-stop-address-time">
|
||||
<div class="pl-plan-stop-address-time__addr">{{ getStopAddress(row) }}</div>
|
||||
<div class="pl-plan-stop-address-time__time">{{ getStopTime(row) }}</div>
|
||||
</div>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column
|
||||
v-if="isColumnVisible('productName')"
|
||||
label="产品名称"
|
||||
min-width="160"
|
||||
align="left"
|
||||
header-align="left"
|
||||
class-name="col-name-wrap pl-plan-stop-col"
|
||||
label-class-name="col-name-wrap"
|
||||
>
|
||||
<template #default="{ row }">
|
||||
<PlPlanListProductCell
|
||||
:stop-products="getStopProducts(row)"
|
||||
:plan-products="row.plan.products"
|
||||
field="name"
|
||||
/>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column
|
||||
v-if="isColumnVisible('productSpec')"
|
||||
label="型号/规格"
|
||||
min-width="96"
|
||||
align="center"
|
||||
header-align="center"
|
||||
class-name="pl-plan-stop-col"
|
||||
show-overflow-tooltip
|
||||
>
|
||||
<template #default="{ row }">
|
||||
<PlPlanListProductCell
|
||||
:stop-products="getStopProducts(row)"
|
||||
:plan-products="row.plan.products"
|
||||
field="spec"
|
||||
/>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column
|
||||
v-if="isColumnVisible('productUnit')"
|
||||
label="单位"
|
||||
min-width="64"
|
||||
align="center"
|
||||
header-align="center"
|
||||
class-name="pl-plan-stop-col"
|
||||
>
|
||||
<template #default="{ row }">
|
||||
<PlPlanListProductCell
|
||||
:stop-products="getStopProducts(row)"
|
||||
:plan-products="row.plan.products"
|
||||
field="unit"
|
||||
/>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column
|
||||
v-if="isColumnVisible('productPlanQty')"
|
||||
label="计划数量"
|
||||
min-width="88"
|
||||
align="right"
|
||||
header-align="right"
|
||||
class-name="pl-plan-stop-col"
|
||||
>
|
||||
<template #default="{ row }">
|
||||
<PlPlanListProductCell
|
||||
:stop-products="getStopProducts(row)"
|
||||
:plan-products="row.plan.products"
|
||||
field="planQty"
|
||||
/>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column
|
||||
v-if="isColumnVisible('productActualQty')"
|
||||
label="实际数量"
|
||||
min-width="88"
|
||||
align="right"
|
||||
header-align="right"
|
||||
class-name="pl-plan-stop-col"
|
||||
>
|
||||
<template #default="{ row }">
|
||||
<PlPlanListProductCell
|
||||
:stop-products="getStopProducts(row)"
|
||||
:plan-products="row.plan.products"
|
||||
field="actualQty"
|
||||
/>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column
|
||||
v-if="isColumnVisible('productInboundQty')"
|
||||
label="入库数量"
|
||||
min-width="88"
|
||||
align="right"
|
||||
header-align="right"
|
||||
class-name="pl-plan-stop-col"
|
||||
>
|
||||
<template #default="{ row }">
|
||||
<PlPlanListProductCell
|
||||
:stop-products="getStopProducts(row)"
|
||||
:plan-products="row.plan.products"
|
||||
field="inboundQty"
|
||||
/>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column
|
||||
v-if="isColumnVisible('productOutboundQty')"
|
||||
label="出库数量"
|
||||
min-width="88"
|
||||
align="right"
|
||||
header-align="right"
|
||||
class-name="pl-plan-stop-col"
|
||||
>
|
||||
<template #default="{ row }">
|
||||
<PlPlanListProductCell
|
||||
:stop-products="getStopProducts(row)"
|
||||
:plan-products="row.plan.products"
|
||||
field="outboundQty"
|
||||
/>
|
||||
</template>
|
||||
</el-table-column>
|
||||
</ListTable>
|
||||
|
||||
<div class="pagination list-pager-bar">
|
||||
@@ -452,6 +532,7 @@ import {
|
||||
planHasHazardProducts
|
||||
} from '@/composables/usePlToxicProductCertCheck'
|
||||
import { usePersistedListColumns } from '@/composables/usePersistedListColumns'
|
||||
import { usePlPlanMergeListTable } from '@/composables/usePlPlanMergeListTable'
|
||||
import PlPlanViewDialog from '@/components/business/pl-plan-view-dialog/index.vue'
|
||||
import PlPlanTypeTabs from '@/components/business/pl-plan-type-tabs/index.vue'
|
||||
import ListToolbarDateShortcuts from '@/components/core/list-toolbar-date-shortcuts/index.vue'
|
||||
@@ -469,10 +550,31 @@ import {
|
||||
type PlPlanCertTab
|
||||
} from '@/utils/pl-display'
|
||||
import { syncViewRowFromFlatList } from '@/utils/view-dialog-refresh'
|
||||
import {
|
||||
getPlPlanListRowClassName,
|
||||
getStopAddress,
|
||||
getStopCustomerName,
|
||||
getStopKindLabel,
|
||||
getStopProducts,
|
||||
getStopTime
|
||||
} from '@/utils/pl-plan-list-display-rows'
|
||||
import { isPlInternalCustomerName } from '@/utils/pl-internal-customer'
|
||||
import { refreshMenuBadges } from '@/utils/menu-badge-registry'
|
||||
import { useMenuStore } from '@/store/modules/menu'
|
||||
|
||||
const menuStore = useMenuStore()
|
||||
|
||||
const PLAN_MERGE_COLUMN_PROPS = [
|
||||
'planDate',
|
||||
'planType',
|
||||
'followStatus',
|
||||
'hazardCertReady',
|
||||
'planAttachments',
|
||||
'licensePlate',
|
||||
'personnelSummary',
|
||||
'followUserName'
|
||||
] as const
|
||||
|
||||
const loading = ref(false)
|
||||
const { mediaActive } = useListMediaActive()
|
||||
const certReadyLoading = ref(false)
|
||||
@@ -485,22 +587,23 @@ const planList = ref<Plan[]>([])
|
||||
|
||||
const listColumnDefs = [
|
||||
{ prop: 'planDate', label: '计划日期' },
|
||||
{ prop: 'supplierName', label: '供方' },
|
||||
{ prop: 'customerName', label: '需方' },
|
||||
{ prop: 'planType', label: '单据类型' },
|
||||
{ prop: 'followStatus', label: '跟进状态' },
|
||||
{ prop: 'hazardCertReady', label: '证书齐备' },
|
||||
{ prop: 'planAttachments', label: '计划附件' },
|
||||
{ prop: 'licensePlate', label: '车牌号' },
|
||||
{ prop: 'personnelSummary', label: '人员' },
|
||||
{ prop: 'followUserName', label: '跟进人', defaultVisible: false },
|
||||
{ prop: 'stopKind', label: '段次' },
|
||||
{ prop: 'stopCustomer', label: '客户' },
|
||||
{ prop: 'stopAddressTime', label: '地址 / 时间' },
|
||||
{ prop: 'productName', label: '产品名称' },
|
||||
{ prop: 'productSpec', label: '型号/规格' },
|
||||
{ prop: 'productUnit', label: '单位' },
|
||||
{ prop: 'productPlanQty', label: '计划数量' },
|
||||
{ prop: 'productActualQty', label: '实际数量' },
|
||||
{ prop: 'productInboundQty', label: '入库数量' },
|
||||
{ prop: 'productOutboundQty', label: '出库数量' },
|
||||
{ prop: 'planAttachments', label: '计划附件' },
|
||||
{ prop: 'licensePlate', label: '车牌号' },
|
||||
{ prop: 'personnelSummary', label: '人员' },
|
||||
{ prop: 'followUserName', label: '跟进人', defaultVisible: false }
|
||||
{ prop: 'productOutboundQty', label: '出库数量' }
|
||||
]
|
||||
|
||||
const {
|
||||
@@ -509,9 +612,34 @@ const {
|
||||
isIndeterminate,
|
||||
isColumnVisible,
|
||||
resetToDefault
|
||||
} = usePersistedListColumns('pl-plan-cert-list-columns', listColumnDefs)
|
||||
} = usePersistedListColumns('pl-plan-cert-list-columns-v3', listColumnDefs)
|
||||
|
||||
const selectedRows = ref<Plan[]>([])
|
||||
|
||||
const pagination = reactive({
|
||||
page: 1,
|
||||
pageSize: 20,
|
||||
total: 0
|
||||
})
|
||||
|
||||
const visiblePlanMergeProps = computed(() =>
|
||||
PLAN_MERGE_COLUMN_PROPS.filter((prop) => isColumnVisible(prop))
|
||||
)
|
||||
|
||||
const {
|
||||
displayRows,
|
||||
planListSpanMethod,
|
||||
getDisplayRowIndex,
|
||||
isPlanFirstRowSelectable,
|
||||
handleDisplaySelectionChange,
|
||||
handleDisplayRowDblClick
|
||||
} = usePlPlanMergeListTable({
|
||||
planList,
|
||||
visiblePlanMergeProps,
|
||||
selectedRows,
|
||||
pagination,
|
||||
onView: (plan) => handleView(plan)
|
||||
})
|
||||
function getPlanCertExportFilterParams() {
|
||||
const keyword = quickSearch.value.trim()
|
||||
return {
|
||||
@@ -528,7 +656,8 @@ function getPlanCertExportFilterParams() {
|
||||
}
|
||||
|
||||
const planCertExportColumns = computed(() => {
|
||||
const cols = [...visibleColumns.value]
|
||||
const skip = new Set(['stopKind', 'stopCustomer', 'stopAddressTime'])
|
||||
const cols = visibleColumns.value.filter((col) => !skip.has(col))
|
||||
if (!cols.includes('planNo')) cols.unshift('planNo')
|
||||
return cols
|
||||
})
|
||||
@@ -547,12 +676,6 @@ const searchForm = reactive({
|
||||
certUploadStatus: '' as string
|
||||
})
|
||||
|
||||
const pagination = reactive({
|
||||
page: 1,
|
||||
pageSize: 20,
|
||||
total: 0
|
||||
})
|
||||
|
||||
function getPlanTypeLabel(type: string) {
|
||||
const map: Record<string, string> = { direct: '直销单', inbound: '入库单', outbound: '出库单' }
|
||||
return map[type] || type
|
||||
@@ -635,10 +758,6 @@ function handleSizeChange() {
|
||||
fetchData()
|
||||
}
|
||||
|
||||
function handleSelectionChange(selection: Plan[]) {
|
||||
selectedRows.value = selection
|
||||
}
|
||||
|
||||
function canUploadCert(row: Plan) {
|
||||
return row.archiveStatus !== 'archived' && row.followStatus !== 'cancelled'
|
||||
}
|
||||
@@ -761,6 +880,8 @@ onMounted(() => {
|
||||
</script>
|
||||
|
||||
<style scoped lang="scss">
|
||||
@use '@styles/business/pl-plan-merge-list-table.scss';
|
||||
|
||||
.pl-plan-list-toolbar-row {
|
||||
flex-wrap: wrap;
|
||||
}
|
||||
|
||||
@@ -88,44 +88,45 @@
|
||||
<div class="list-body list-wrap">
|
||||
<el-table
|
||||
ref="tableRef"
|
||||
class="list-table"
|
||||
:data="tableData"
|
||||
class="list-table pl-plan-merge-list-table"
|
||||
:data="displayRows"
|
||||
v-loading="loading"
|
||||
stripe
|
||||
row-key="id"
|
||||
row-key="rowKey"
|
||||
:span-method="planListSpanMethod"
|
||||
:row-class-name="getPlPlanListRowClassName"
|
||||
:expand-row-keys="expandedRowKeys"
|
||||
@expand-change="handleExpandChange"
|
||||
@row-dblclick="handleView"
|
||||
@row-dblclick="handleDisplayRowDblClick"
|
||||
>
|
||||
<el-table-column type="expand" class-name="pl-contract-expand-col" width="1">
|
||||
<template #default="{ row }">
|
||||
<div class="pl-contract-expand" v-if="expandDraft[row.id]">
|
||||
<div class="pl-contract-expand" v-if="expandDraft[row.plan.id]">
|
||||
<div class="pl-contract-expand__grid">
|
||||
<div
|
||||
class="pl-contract-side"
|
||||
:class="sideBoxClass(row, 'supplier')"
|
||||
:class="sideBoxClass(asGapItem(row), 'supplier')"
|
||||
>
|
||||
<div class="pl-contract-side__head">
|
||||
<h4>供方合同</h4>
|
||||
<el-tag
|
||||
:type="sideTagType(row, 'supplier')"
|
||||
:type="sideTagType(asGapItem(row), 'supplier')"
|
||||
size="small"
|
||||
:effect="row.supplierContractExempt ? 'plain' : 'dark'"
|
||||
:effect="asGapItem(row).supplierContractExempt ? 'plain' : 'dark'"
|
||||
>
|
||||
{{ sideTagLabel(row, 'supplier') }}
|
||||
{{ sideTagLabel(asGapItem(row), 'supplier') }}
|
||||
</el-tag>
|
||||
</div>
|
||||
<p class="pl-contract-side__customer">
|
||||
{{ row.supplierName || '—' }}
|
||||
{{ asGapItem(row).supplierName || '—' }}
|
||||
</p>
|
||||
<template v-if="row.supplierContractExempt">
|
||||
<template v-if="asGapItem(row).supplierContractExempt">
|
||||
<p class="pl-contract-side__exempt">内置公司,合同可免</p>
|
||||
</template>
|
||||
<template v-else>
|
||||
<PlPlanContractMultiSelect
|
||||
v-model="expandDraft[row.id].supplierContracts"
|
||||
:customer-id="row.supplierId"
|
||||
:disabled="!row.supplierId"
|
||||
v-model="expandDraft[row.plan.id].supplierContracts"
|
||||
:customer-id="asGapItem(row).supplierId"
|
||||
:disabled="!asGapItem(row).supplierId"
|
||||
:required="false"
|
||||
/>
|
||||
<div class="pl-contract-side__actions">
|
||||
@@ -133,8 +134,8 @@
|
||||
class="btn-main"
|
||||
type="primary"
|
||||
size="small"
|
||||
:loading="savingKey === `${row.id}:supplier`"
|
||||
@click="handleSaveSide(row, 'supplier')"
|
||||
:loading="savingKey === `${row.plan.id}:supplier`"
|
||||
@click="handleSaveSide(asGapItem(row), 'supplier')"
|
||||
>
|
||||
<el-icon><Check /></el-icon>保存供方合同
|
||||
</el-button>
|
||||
@@ -144,29 +145,29 @@
|
||||
|
||||
<div
|
||||
class="pl-contract-side"
|
||||
:class="sideBoxClass(row, 'demander')"
|
||||
:class="sideBoxClass(asGapItem(row), 'demander')"
|
||||
>
|
||||
<div class="pl-contract-side__head">
|
||||
<h4>需方合同</h4>
|
||||
<el-tag
|
||||
:type="sideTagType(row, 'demander')"
|
||||
:type="sideTagType(asGapItem(row), 'demander')"
|
||||
size="small"
|
||||
:effect="row.demanderContractExempt ? 'plain' : 'dark'"
|
||||
:effect="asGapItem(row).demanderContractExempt ? 'plain' : 'dark'"
|
||||
>
|
||||
{{ sideTagLabel(row, 'demander') }}
|
||||
{{ sideTagLabel(asGapItem(row), 'demander') }}
|
||||
</el-tag>
|
||||
</div>
|
||||
<p class="pl-contract-side__customer">
|
||||
{{ row.customerName || '—' }}
|
||||
{{ asGapItem(row).customerName || '—' }}
|
||||
</p>
|
||||
<template v-if="row.demanderContractExempt">
|
||||
<template v-if="asGapItem(row).demanderContractExempt">
|
||||
<p class="pl-contract-side__exempt">内置公司,合同可免</p>
|
||||
</template>
|
||||
<template v-else>
|
||||
<PlPlanContractMultiSelect
|
||||
v-model="expandDraft[row.id].demanderContracts"
|
||||
:customer-id="row.customerId"
|
||||
:disabled="!row.customerId"
|
||||
v-model="expandDraft[row.plan.id].demanderContracts"
|
||||
:customer-id="asGapItem(row).customerId"
|
||||
:disabled="!asGapItem(row).customerId"
|
||||
:required="false"
|
||||
/>
|
||||
<div class="pl-contract-side__actions">
|
||||
@@ -174,8 +175,8 @@
|
||||
class="btn-main"
|
||||
type="primary"
|
||||
size="small"
|
||||
:loading="savingKey === `${row.id}:demander`"
|
||||
@click="handleSaveSide(row, 'demander')"
|
||||
:loading="savingKey === `${row.plan.id}:demander`"
|
||||
@click="handleSaveSide(asGapItem(row), 'demander')"
|
||||
>
|
||||
<el-icon><Check /></el-icon>保存需方合同
|
||||
</el-button>
|
||||
@@ -192,17 +193,79 @@
|
||||
label="序号"
|
||||
width="68"
|
||||
align="center"
|
||||
:index="index => (pagination.page - 1) * pagination.pageSize + index + 1"
|
||||
:index="getDisplayRowIndex"
|
||||
/>
|
||||
<el-table-column prop="planNo" label="计划编号" min-width="150" show-overflow-tooltip>
|
||||
<template #default="{ row }">
|
||||
<el-link type="primary" @click="handleView(row)">{{ row.planNo }}</el-link>
|
||||
<el-link type="primary" @click="handleView(asGapItem(row))">{{
|
||||
row.plan.planNo
|
||||
}}</el-link>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column prop="planDate" label="计划日期" min-width="120" align="center" />
|
||||
<el-table-column prop="planDate" label="计划日期" min-width="120" align="center">
|
||||
<template #default="{ row }">{{ asGapItem(row).planDate || '—' }}</template>
|
||||
</el-table-column>
|
||||
<el-table-column prop="planType" label="单据类型" min-width="100" align="center">
|
||||
<template #default="{ row }">
|
||||
{{ getPlanTypeLabel(row.planType) }}
|
||||
{{ getPlanTypeLabel(asGapItem(row).planType) }}
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column prop="followStatus" label="跟进状态" min-width="110" align="center">
|
||||
<template #default="{ row }">
|
||||
<el-tag
|
||||
:type="getPlPlanFollowStatusTagType(asGapItem(row).followStatus)"
|
||||
size="small"
|
||||
effect="dark"
|
||||
>
|
||||
{{ getPlPlanFollowStatusLabel(asGapItem(row).followStatus) }}
|
||||
</el-tag>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column
|
||||
prop="stopKind"
|
||||
label="段次"
|
||||
min-width="88"
|
||||
align="center"
|
||||
class-name="pl-plan-stop-col"
|
||||
>
|
||||
<template #default="{ row }">
|
||||
<span class="pl-plan-stop-kind-text">{{ getStopKindLabel(row) }}</span>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column
|
||||
prop="stopCustomer"
|
||||
label="客户"
|
||||
min-width="200"
|
||||
align="left"
|
||||
class-name="col-name-wrap pl-plan-stop-col"
|
||||
label-class-name="col-name-wrap"
|
||||
show-overflow-tooltip
|
||||
>
|
||||
<template #default="{ row }">
|
||||
<span>{{ getStopCustomerName(row) }}</span>
|
||||
<el-tag
|
||||
v-if="isPlInternalCustomerName(getStopCustomerName(row))"
|
||||
type="success"
|
||||
size="small"
|
||||
class="pl-plan-internal-customer-tag"
|
||||
>
|
||||
内部
|
||||
</el-tag>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column
|
||||
prop="stopAddressTime"
|
||||
label="地址 / 时间"
|
||||
min-width="220"
|
||||
align="left"
|
||||
class-name="col-name-wrap pl-plan-stop-col"
|
||||
label-class-name="col-name-wrap"
|
||||
>
|
||||
<template #default="{ row }">
|
||||
<div class="pl-plan-stop-address-time">
|
||||
<div class="pl-plan-stop-address-time__addr">{{ getStopAddress(row) }}</div>
|
||||
<div class="pl-plan-stop-address-time__time">{{ getStopTime(row) }}</div>
|
||||
</div>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column
|
||||
@@ -210,14 +273,14 @@
|
||||
min-width="260"
|
||||
align="left"
|
||||
header-align="left"
|
||||
class-name="col-name-wrap"
|
||||
class-name="col-name-wrap pl-plan-stop-col"
|
||||
label-class-name="col-name-wrap"
|
||||
>
|
||||
<template #default="{ row }">
|
||||
<div class="pl-gap-contract-cell">
|
||||
<div class="pl-plan-contract-cell">
|
||||
<div
|
||||
v-for="(line, index) in planContractLines(row)"
|
||||
v-for="(line, index) in getContractGapStopLines(row)"
|
||||
:key="`${line.side}-${line.no}-${index}`"
|
||||
class="pl-plan-contract-cell__row"
|
||||
>
|
||||
@@ -229,104 +292,130 @@
|
||||
</div>
|
||||
</div>
|
||||
<el-button
|
||||
v-if="showGapSupplementAction(row)"
|
||||
link
|
||||
type="warning"
|
||||
class="pl-gap-contract-cell__action"
|
||||
@click.stop="toggleExpand(row)"
|
||||
@click.stop="toggleExpand(asGapItem(row))"
|
||||
>
|
||||
<el-icon><EditPen /></el-icon>
|
||||
{{ isExpanded(row.id) ? '收起' : '补充' }}
|
||||
{{ isExpanded(asGapItem(row).id) ? '收起' : '补充' }}
|
||||
</el-button>
|
||||
</div>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column prop="followStatus" label="跟进状态" min-width="110" align="center">
|
||||
<template #default="{ row }">
|
||||
<el-tag
|
||||
:type="getPlPlanFollowStatusTagType(row.followStatus)"
|
||||
size="small"
|
||||
effect="dark"
|
||||
>
|
||||
{{ getPlPlanFollowStatusLabel(row.followStatus) }}
|
||||
</el-tag>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column
|
||||
prop="supplierName"
|
||||
label="供方"
|
||||
min-width="200"
|
||||
align="left"
|
||||
class-name="col-name-wrap"
|
||||
label-class-name="col-name-wrap"
|
||||
show-overflow-tooltip
|
||||
>
|
||||
<template #default="{ row }">
|
||||
<div class="party-cell">
|
||||
<span>{{ row.supplierName || '—' }}</span>
|
||||
<span class="party-cell__sub">{{ partySubText(row, 'supplier') }}</span>
|
||||
</div>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column
|
||||
prop="customerName"
|
||||
label="需方"
|
||||
min-width="200"
|
||||
align="left"
|
||||
class-name="col-name-wrap"
|
||||
label-class-name="col-name-wrap"
|
||||
show-overflow-tooltip
|
||||
>
|
||||
<template #default="{ row }">
|
||||
<div class="party-cell">
|
||||
<span>{{ row.customerName || '—' }}</span>
|
||||
<span class="party-cell__sub">{{ partySubText(row, 'demander') }}</span>
|
||||
</div>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column
|
||||
label="产品名称"
|
||||
min-width="160"
|
||||
align="left"
|
||||
class-name="col-name-wrap"
|
||||
class-name="col-name-wrap pl-plan-stop-col"
|
||||
label-class-name="col-name-wrap"
|
||||
>
|
||||
<template #default="{ row }">
|
||||
<PlPlanListProductCell :products="row.products" field="name" />
|
||||
<PlPlanListProductCell
|
||||
:stop-products="getStopProducts(row)"
|
||||
:plan-products="asGapItem(row).products"
|
||||
field="name"
|
||||
/>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="型号/规格" min-width="120" align="center" show-overflow-tooltip>
|
||||
<el-table-column
|
||||
label="型号/规格"
|
||||
min-width="120"
|
||||
align="center"
|
||||
class-name="pl-plan-stop-col"
|
||||
show-overflow-tooltip
|
||||
>
|
||||
<template #default="{ row }">
|
||||
<PlPlanListProductCell :products="row.products" field="model" />
|
||||
<PlPlanListProductCell
|
||||
:stop-products="getStopProducts(row)"
|
||||
:plan-products="asGapItem(row).products"
|
||||
field="model"
|
||||
/>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="包装规格" min-width="120" align="center" show-overflow-tooltip>
|
||||
<el-table-column
|
||||
label="包装规格"
|
||||
min-width="120"
|
||||
align="center"
|
||||
class-name="pl-plan-stop-col"
|
||||
show-overflow-tooltip
|
||||
>
|
||||
<template #default="{ row }">
|
||||
<PlPlanListProductCell :products="row.products" field="packageSpec" />
|
||||
<PlPlanListProductCell
|
||||
:stop-products="getStopProducts(row)"
|
||||
:plan-products="asGapItem(row).products"
|
||||
field="packageSpec"
|
||||
/>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="单位" min-width="80" align="center">
|
||||
<el-table-column label="单位" min-width="80" align="center" class-name="pl-plan-stop-col">
|
||||
<template #default="{ row }">
|
||||
<PlPlanListProductCell :products="row.products" field="unit" />
|
||||
<PlPlanListProductCell
|
||||
:stop-products="getStopProducts(row)"
|
||||
:plan-products="asGapItem(row).products"
|
||||
field="unit"
|
||||
/>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="计划数量" min-width="100" align="right" header-align="right">
|
||||
<el-table-column
|
||||
label="计划数量"
|
||||
min-width="100"
|
||||
align="right"
|
||||
header-align="right"
|
||||
class-name="pl-plan-stop-col"
|
||||
>
|
||||
<template #default="{ row }">
|
||||
<PlPlanListProductCell :products="row.products" field="planQty" />
|
||||
<PlPlanListProductCell
|
||||
:stop-products="getStopProducts(row)"
|
||||
:plan-products="asGapItem(row).products"
|
||||
field="planQty"
|
||||
/>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="实际数量" min-width="100" align="right" header-align="right">
|
||||
<el-table-column
|
||||
label="实际数量"
|
||||
min-width="100"
|
||||
align="right"
|
||||
header-align="right"
|
||||
class-name="pl-plan-stop-col"
|
||||
>
|
||||
<template #default="{ row }">
|
||||
<PlPlanListProductCell :products="row.products" field="actualQty" />
|
||||
<PlPlanListProductCell
|
||||
:stop-products="getStopProducts(row)"
|
||||
:plan-products="asGapItem(row).products"
|
||||
field="actualQty"
|
||||
/>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="入库数量" min-width="100" align="right" header-align="right">
|
||||
<el-table-column
|
||||
label="入库数量"
|
||||
min-width="100"
|
||||
align="right"
|
||||
header-align="right"
|
||||
class-name="pl-plan-stop-col"
|
||||
>
|
||||
<template #default="{ row }">
|
||||
<PlPlanListProductCell :products="row.products" field="inboundQty" />
|
||||
<PlPlanListProductCell
|
||||
:stop-products="getStopProducts(row)"
|
||||
:plan-products="asGapItem(row).products"
|
||||
field="inboundQty"
|
||||
/>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="出库数量" min-width="100" align="right" header-align="right">
|
||||
<el-table-column
|
||||
label="出库数量"
|
||||
min-width="100"
|
||||
align="right"
|
||||
header-align="right"
|
||||
class-name="pl-plan-stop-col"
|
||||
>
|
||||
<template #default="{ row }">
|
||||
<PlPlanListProductCell :products="row.products" field="outboundQty" />
|
||||
<PlPlanListProductCell
|
||||
:stop-products="getStopProducts(row)"
|
||||
:plan-products="asGapItem(row).products"
|
||||
field="outboundQty"
|
||||
/>
|
||||
</template>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
@@ -369,14 +458,28 @@ import ListQuickSearchInput from '@/components/business/list-quick-search-input/
|
||||
import ListExportDropdown from '@/components/business/list-export-dropdown/index.vue'
|
||||
import ListToolbarDateShortcuts from '@/components/core/list-toolbar-date-shortcuts/index.vue'
|
||||
import { useListDateShortcut } from '@/composables/useListDateShortcut'
|
||||
import { usePlPlanMergeListTable } from '@/composables/usePlPlanMergeListTable'
|
||||
import {
|
||||
getPlPlanFollowStatusLabel,
|
||||
getPlPlanFollowStatusTagType
|
||||
} from '@/utils/pl-display'
|
||||
import { planContractLines } from '@/utils/pl-plan-contract-display'
|
||||
import { planContractSideLines } from '@/utils/pl-plan-contract-display'
|
||||
import {
|
||||
getPlPlanListRowClassName,
|
||||
getStopAddress,
|
||||
getStopContractLines,
|
||||
getStopCustomerName,
|
||||
getStopKindLabel,
|
||||
getStopProducts,
|
||||
getStopTime,
|
||||
type PlPlanListDisplayRow
|
||||
} from '@/utils/pl-plan-list-display-rows'
|
||||
import { isPlInternalCustomerName } from '@/utils/pl-internal-customer'
|
||||
import { refreshMenuBadges } from '@/utils/menu-badge-registry'
|
||||
import { useMenuStore } from '@/store/modules/menu'
|
||||
|
||||
const PLAN_MERGE_COLUMN_PROPS = ['planDate', 'planType', 'followStatus'] as const
|
||||
|
||||
const menuStore = useMenuStore()
|
||||
const loading = ref(false)
|
||||
const tableRef = ref()
|
||||
@@ -412,6 +515,60 @@ const pagination = reactive({
|
||||
total: 0
|
||||
})
|
||||
|
||||
const planListForDisplay = computed(() => tableData.value as unknown as import('@/api/pl').Plan[])
|
||||
|
||||
const visiblePlanMergeProps = computed(() => [...PLAN_MERGE_COLUMN_PROPS])
|
||||
|
||||
const {
|
||||
displayRows,
|
||||
planListSpanMethod,
|
||||
getDisplayRowIndex,
|
||||
handleDisplayRowDblClick,
|
||||
findPlanFirstDisplayRow
|
||||
} = usePlPlanMergeListTable({
|
||||
planList: planListForDisplay,
|
||||
visiblePlanMergeProps,
|
||||
selectedRows: ref([]),
|
||||
pagination,
|
||||
onView: (plan) => handleView(plan as unknown as PlanContractGapItem)
|
||||
})
|
||||
|
||||
function asGapItem(row: PlPlanListDisplayRow): PlanContractGapItem {
|
||||
return row.plan as unknown as PlanContractGapItem
|
||||
}
|
||||
|
||||
/** 段内合同缺口:装货行展示供方,送货行展示需方 */
|
||||
function getContractGapStopLines(row: PlPlanListDisplayRow) {
|
||||
if ((row.stop.contracts?.length ?? 0) > 0) {
|
||||
return getStopContractLines(row)
|
||||
}
|
||||
const gap = asGapItem(row)
|
||||
if (row.kind === 'load') {
|
||||
return planContractSideLines(
|
||||
'供',
|
||||
gap.supplierContracts,
|
||||
gap.supplierName || row.stop.customerName
|
||||
)
|
||||
}
|
||||
return planContractSideLines(
|
||||
'需',
|
||||
gap.demanderContracts,
|
||||
row.stop.customerName || gap.customerName
|
||||
)
|
||||
}
|
||||
|
||||
function showGapSupplementAction(row: PlPlanListDisplayRow): boolean {
|
||||
const gap = asGapItem(row)
|
||||
if (row.kind === 'load') {
|
||||
return !gap.supplierContractExempt && (gap.gapSides || []).includes('supplier')
|
||||
}
|
||||
return !gap.demanderContractExempt && (gap.gapSides || []).includes('demander')
|
||||
}
|
||||
|
||||
function gapExpandRowKey(planId: string) {
|
||||
return `${planId}-load`
|
||||
}
|
||||
|
||||
function getContractGapExportFilterParams() {
|
||||
const keyword = quickSearch.value.trim()
|
||||
return {
|
||||
@@ -458,17 +615,6 @@ function getPlanTypeLabel(type?: string | null) {
|
||||
return type ? map[type] || type : '—'
|
||||
}
|
||||
|
||||
function partySubText(row: PlanContractGapItem, side: 'supplier' | 'demander') {
|
||||
if (side === 'supplier') {
|
||||
if (row.supplierContractExempt) return '内置 · 合同可免'
|
||||
const n = row.supplierContracts?.length || 0
|
||||
return n ? `已关联${n}份合同` : '未关联合同'
|
||||
}
|
||||
if (row.demanderContractExempt) return '内置 · 合同可免'
|
||||
const n = row.demanderContracts?.length || 0
|
||||
return n ? `已关联${n}份合同` : '未关联合同'
|
||||
}
|
||||
|
||||
function sideBoxClass(row: PlanContractGapItem, side: 'supplier' | 'demander') {
|
||||
const exempt = side === 'supplier' ? row.supplierContractExempt : row.demanderContractExempt
|
||||
if (exempt) return 'is-exempt'
|
||||
@@ -489,7 +635,7 @@ function sideTagType(row: PlanContractGapItem, side: 'supplier' | 'demander') {
|
||||
}
|
||||
|
||||
function isExpanded(id: string) {
|
||||
return expandedRowKeys.value.includes(id)
|
||||
return expandedRowKeys.value.includes(gapExpandRowKey(id))
|
||||
}
|
||||
|
||||
function ensureDraft(row: PlanContractGapItem) {
|
||||
@@ -526,18 +672,19 @@ async function collapseRow(id: string) {
|
||||
}
|
||||
}
|
||||
delete expandDraft[id]
|
||||
expandedRowKeys.value = expandedRowKeys.value.filter(key => key !== id)
|
||||
expandedRowKeys.value = expandedRowKeys.value.filter((key) => key !== gapExpandRowKey(id))
|
||||
return true
|
||||
}
|
||||
|
||||
async function expandRow(row: PlanContractGapItem) {
|
||||
const current = expandedRowKeys.value[0]
|
||||
if (current && current !== row.id) {
|
||||
const ok = await collapseRow(current)
|
||||
const currentKey = expandedRowKeys.value[0]
|
||||
const currentId = currentKey?.replace(/-load$/, '')
|
||||
if (currentId && currentId !== row.id) {
|
||||
const ok = await collapseRow(currentId)
|
||||
if (!ok) return
|
||||
}
|
||||
ensureDraft(row)
|
||||
expandedRowKeys.value = [row.id]
|
||||
expandedRowKeys.value = [gapExpandRowKey(row.id)]
|
||||
}
|
||||
|
||||
async function toggleExpand(row: PlanContractGapItem) {
|
||||
@@ -548,26 +695,33 @@ async function toggleExpand(row: PlanContractGapItem) {
|
||||
}
|
||||
}
|
||||
|
||||
async function handleExpandChange(row: PlanContractGapItem, expandedRows: PlanContractGapItem[]) {
|
||||
const willExpand = expandedRows.some(item => item.id === row.id)
|
||||
async function handleExpandChange(
|
||||
displayRow: PlPlanListDisplayRow,
|
||||
expandedRows: PlPlanListDisplayRow[]
|
||||
) {
|
||||
const gap = asGapItem(displayRow)
|
||||
const willExpand = expandedRows.some((item) => item.rowKey === displayRow.rowKey)
|
||||
if (willExpand) {
|
||||
const current = expandedRowKeys.value[0]
|
||||
if (current && current !== row.id) {
|
||||
const ok = await collapseRow(current)
|
||||
const currentKey = expandedRowKeys.value[0]
|
||||
const currentId = currentKey?.replace(/-load$/, '')
|
||||
if (currentId && currentId !== gap.id) {
|
||||
const ok = await collapseRow(currentId)
|
||||
if (!ok) {
|
||||
nextTick(() => {
|
||||
tableRef.value?.toggleRowExpansion?.(row, false)
|
||||
const firstRow = findPlanFirstDisplayRow(gap.id)
|
||||
if (firstRow) tableRef.value?.toggleRowExpansion?.(firstRow, false)
|
||||
})
|
||||
return
|
||||
}
|
||||
}
|
||||
ensureDraft(row)
|
||||
expandedRowKeys.value = [row.id]
|
||||
} else if (expandedRowKeys.value.includes(row.id)) {
|
||||
const ok = await collapseRow(row.id)
|
||||
ensureDraft(gap)
|
||||
expandedRowKeys.value = [gapExpandRowKey(gap.id)]
|
||||
} else if (expandedRowKeys.value.includes(gapExpandRowKey(gap.id))) {
|
||||
const ok = await collapseRow(gap.id)
|
||||
if (!ok) {
|
||||
nextTick(() => {
|
||||
tableRef.value?.toggleRowExpansion?.(row, true)
|
||||
const firstRow = findPlanFirstDisplayRow(gap.id)
|
||||
if (firstRow) tableRef.value?.toggleRowExpansion?.(firstRow, true)
|
||||
})
|
||||
}
|
||||
}
|
||||
@@ -591,8 +745,11 @@ async function fetchData() {
|
||||
tableData.value = data.list || []
|
||||
pagination.total = data.total || 0
|
||||
// 收起已不在列表中的展开行
|
||||
const ids = new Set(tableData.value.map(item => item.id))
|
||||
expandedRowKeys.value = expandedRowKeys.value.filter(id => ids.has(id))
|
||||
const ids = new Set(tableData.value.map((item) => item.id))
|
||||
expandedRowKeys.value = expandedRowKeys.value.filter((key) => {
|
||||
const planId = key.replace(/-load$/, '')
|
||||
return ids.has(planId)
|
||||
})
|
||||
Object.keys(expandDraft).forEach(id => {
|
||||
if (!ids.has(id)) delete expandDraft[id]
|
||||
})
|
||||
@@ -687,6 +844,8 @@ onMounted(() => {
|
||||
</script>
|
||||
|
||||
<style scoped lang="scss">
|
||||
@use '@styles/business/pl-plan-merge-list-table.scss';
|
||||
|
||||
.pl-plan-list-toolbar-row {
|
||||
flex-wrap: nowrap;
|
||||
overflow-x: auto;
|
||||
@@ -714,18 +873,6 @@ onMounted(() => {
|
||||
border: 1px solid rgba(217, 119, 6, 0.2);
|
||||
}
|
||||
|
||||
.party-cell {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 2px;
|
||||
line-height: 1.4;
|
||||
}
|
||||
|
||||
.party-cell__sub {
|
||||
font-size: 12px;
|
||||
color: var(--el-text-color-secondary, #64748b);
|
||||
}
|
||||
|
||||
.pl-contract-expand {
|
||||
padding: 12px 16px 16px;
|
||||
background: #f8fffb;
|
||||
|
||||
@@ -188,10 +188,11 @@
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<PlPlanArrangeDialog
|
||||
v-model:visible="arrangeDialogVisible"
|
||||
<PlPlanFormDialog
|
||||
v-model:visible="formDialogVisible"
|
||||
:plan-id="planId"
|
||||
@success="fetchDetail"
|
||||
:open-for-arrange="formOpenForArrange"
|
||||
@success="handleFormSuccess"
|
||||
/>
|
||||
</div>
|
||||
</template>
|
||||
@@ -204,7 +205,7 @@ import {
|
||||
Van
|
||||
} from '@element-plus/icons-vue'
|
||||
import { planApi, type Plan, type PlanProduct } from '@/api/pl'
|
||||
import PlPlanArrangeDialog from '@/components/business/pl-plan-arrange-dialog/index.vue'
|
||||
import PlPlanFormDialog from '@/components/business/pl-plan-form-dialog/index.vue'
|
||||
import { formatMoneyDisplay } from '@/utils/money-format'
|
||||
import {
|
||||
getPlPlanFollowStatusLabel,
|
||||
@@ -217,7 +218,8 @@ const router = useRouter()
|
||||
const planId = computed(() => route.params.id as string)
|
||||
|
||||
const loading = ref(false)
|
||||
const arrangeDialogVisible = ref(false)
|
||||
const formDialogVisible = ref(false)
|
||||
const formOpenForArrange = ref(false)
|
||||
const plan = ref<Partial<Plan>>({})
|
||||
const products = ref<PlanProduct[]>([])
|
||||
|
||||
@@ -267,7 +269,16 @@ function handleEdit() {
|
||||
}
|
||||
|
||||
function handleArrange() {
|
||||
arrangeDialogVisible.value = true
|
||||
formOpenForArrange.value = true
|
||||
formDialogVisible.value = true
|
||||
}
|
||||
|
||||
async function handleFormSuccess(payload?: { planId?: string; arranged?: boolean }) {
|
||||
formOpenForArrange.value = false
|
||||
await fetchDetail()
|
||||
if (payload?.arranged) {
|
||||
ElMessage.success('运输安排成功,可在列表页查看并复制链接')
|
||||
}
|
||||
}
|
||||
|
||||
async function handleCancel() {
|
||||
|
||||
+1329
-1038
File diff suppressed because it is too large.
Load diff
@@ -30,6 +30,192 @@
|
||||
/>
|
||||
</van-cell-group>
|
||||
|
||||
<template v-if="useMultiStop">
|
||||
<van-cell-group
|
||||
v-for="stop in stopStates"
|
||||
:key="`${stop.stopType}-${stop.stopId}`"
|
||||
inset
|
||||
class="section-card"
|
||||
:title="`${stop.label} · ${stop.customerName}`"
|
||||
>
|
||||
<van-cell title="地址" class="address-cell multiline-cell">
|
||||
<template #value>
|
||||
<div class="address-cell__content">
|
||||
<span class="address-cell__text">{{ stop.address || '—' }}</span>
|
||||
<van-button
|
||||
v-if="buildStopNavUrl(stop)"
|
||||
size="mini"
|
||||
type="primary"
|
||||
round
|
||||
class="address-nav-btn"
|
||||
@click="openStopNavigation(stop)"
|
||||
>
|
||||
导航
|
||||
</van-button>
|
||||
</div>
|
||||
</template>
|
||||
</van-cell>
|
||||
<van-cell title="联系方式" :value="stop.contact || '—'" class="multiline-cell" />
|
||||
<van-cell title="注意事项" :value="stop.notes || '—'" class="multiline-cell" />
|
||||
<div v-if="stop.showProductQty && stop.editableProducts.length" class="stop-products-wrap">
|
||||
<div class="stop-products-title">产品实际数量</div>
|
||||
<div
|
||||
v-for="(item, idx) in stop.editableProducts"
|
||||
:key="item.stopProductId"
|
||||
class="product-card"
|
||||
>
|
||||
<div class="product-card__head">
|
||||
<div class="product-card__head-main">
|
||||
<span class="product-card__badge">
|
||||
{{ idx + 1 }}/{{ stop.editableProducts.length }}
|
||||
</span>
|
||||
<div class="product-card__name">{{ item.productName || '产品' }}</div>
|
||||
</div>
|
||||
<div class="product-card__plan">
|
||||
<span class="product-card__plan-label">计划</span>
|
||||
<strong>{{ formatStopPlanQty(item) }}</strong>
|
||||
</div>
|
||||
</div>
|
||||
<div class="meta-list">
|
||||
<div class="meta-row">
|
||||
<span class="meta-row__label">别名</span>
|
||||
<span class="meta-row__value">{{ item.aliasName || '—' }}</span>
|
||||
</div>
|
||||
<div class="meta-row">
|
||||
<span class="meta-row__label">品牌</span>
|
||||
<span class="meta-row__value">{{ formatBrandLabel(item) }}</span>
|
||||
</div>
|
||||
<div class="meta-row">
|
||||
<span class="meta-row__label">规格型号</span>
|
||||
<span class="meta-row__value">{{ item.model || '—' }}</span>
|
||||
</div>
|
||||
<div class="meta-row">
|
||||
<span class="meta-row__label">包装规格</span>
|
||||
<span class="meta-row__value">{{ item.packageSpec || '—' }}</span>
|
||||
</div>
|
||||
<div v-if="item.remark" class="meta-row meta-row--span">
|
||||
<span class="meta-row__label">备注</span>
|
||||
<span class="meta-row__value">{{ item.remark }}</span>
|
||||
</div>
|
||||
</div>
|
||||
<div class="actual-box">
|
||||
<div class="actual-box__label">
|
||||
<strong>实际数量</strong>
|
||||
<span v-if="item.brandMode">由品牌明细合计</span>
|
||||
<span v-else>请按现场实装填写</span>
|
||||
</div>
|
||||
<div class="actual-box__row">
|
||||
<van-field
|
||||
v-model="item.actualQtyText"
|
||||
type="number"
|
||||
class="actual-box__field"
|
||||
placeholder="请输入"
|
||||
:border="false"
|
||||
:readonly="isReadOnly || Boolean(item.brandMode)"
|
||||
/>
|
||||
<span class="actual-box__unit">{{ item.unit || '吨' }}</span>
|
||||
</div>
|
||||
<BrandQtyChipsField
|
||||
v-if="item.brandMode"
|
||||
v-model="item.brandQtyRows"
|
||||
:brand-mode="brandModeForField(item)"
|
||||
:required-brand-id="item.brandId"
|
||||
:brand-options="item.brandOptions || []"
|
||||
:disabled="isReadOnly"
|
||||
:unit="item.unit || '吨'"
|
||||
variant="mobile"
|
||||
:actual-qty="Number(item.actualQtyText || 0)"
|
||||
@update:actual-qty="(val) => syncItemActualQty(item, val)"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="stop-uploader-wrap">
|
||||
<div class="stop-uploader-label">附件上传</div>
|
||||
<van-uploader
|
||||
v-model="stop.uploaderFiles"
|
||||
multiple
|
||||
:max-count="9"
|
||||
:deletable="!isReadOnly"
|
||||
:show-upload="!isReadOnly"
|
||||
:after-read="(item) => handleStopAfterRead(stop, item)"
|
||||
:before-delete="(_file, detail) => handleStopBeforeDelete(stop, detail.index)"
|
||||
/>
|
||||
</div>
|
||||
</van-cell-group>
|
||||
</template>
|
||||
|
||||
<van-cell-group
|
||||
v-if="useMultiStop && !hasInternalProductStops && editableItems.length"
|
||||
inset
|
||||
class="section-card"
|
||||
title="产品实际数量"
|
||||
>
|
||||
<div v-for="(item, idx) in editableItems" :key="item.id" class="product-card">
|
||||
<div class="product-card__head">
|
||||
<div class="product-card__head-main">
|
||||
<span class="product-card__badge">
|
||||
{{ idx + 1 }}/{{ editableItems.length }}
|
||||
</span>
|
||||
<div class="product-card__name">{{ item.productName || '产品' }}</div>
|
||||
</div>
|
||||
<div class="product-card__plan">
|
||||
<span class="product-card__plan-label">计划</span>
|
||||
<strong>{{ formatPlanQty(item) }}</strong>
|
||||
</div>
|
||||
</div>
|
||||
<div class="meta-list">
|
||||
<div class="meta-row">
|
||||
<span class="meta-row__label">别名</span>
|
||||
<span class="meta-row__value">{{ item.aliasName || '—' }}</span>
|
||||
</div>
|
||||
<div class="meta-row">
|
||||
<span class="meta-row__label">品牌</span>
|
||||
<span class="meta-row__value">{{ formatBrandLabel(item) }}</span>
|
||||
</div>
|
||||
<div class="meta-row">
|
||||
<span class="meta-row__label">规格型号</span>
|
||||
<span class="meta-row__value">{{ item.specification || '—' }}</span>
|
||||
</div>
|
||||
<div class="meta-row">
|
||||
<span class="meta-row__label">包装规格</span>
|
||||
<span class="meta-row__value">{{ item.packageSpec || '—' }}</span>
|
||||
</div>
|
||||
</div>
|
||||
<div class="actual-box">
|
||||
<div class="actual-box__label">
|
||||
<strong>实际数量</strong>
|
||||
<span v-if="item.brandMode">由品牌明细合计</span>
|
||||
<span v-else>请按现场实装填写</span>
|
||||
</div>
|
||||
<div class="actual-box__row">
|
||||
<van-field
|
||||
v-model="item.actualQtyText"
|
||||
type="number"
|
||||
class="actual-box__field"
|
||||
placeholder="请输入"
|
||||
:border="false"
|
||||
:readonly="isReadOnly || Boolean(item.brandMode)"
|
||||
/>
|
||||
<span class="actual-box__unit">{{ item.unit || '吨' }}</span>
|
||||
</div>
|
||||
<BrandQtyChipsField
|
||||
v-if="item.brandMode"
|
||||
v-model="item.brandQtyRows"
|
||||
:brand-mode="brandModeForField(item)"
|
||||
:required-brand-id="item.brandId"
|
||||
:brand-options="item.brandOptions || []"
|
||||
:disabled="isReadOnly"
|
||||
:unit="item.unit || '吨'"
|
||||
variant="mobile"
|
||||
:actual-qty="Number(item.actualQtyText || 0)"
|
||||
@update:actual-qty="(val) => syncItemActualQty(item, val)"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
</van-cell-group>
|
||||
|
||||
<template v-else>
|
||||
<van-cell-group inset class="section-card" title="取货信息">
|
||||
<van-cell title="取货地址" class="address-cell multiline-cell">
|
||||
<template #value>
|
||||
@@ -154,6 +340,7 @@
|
||||
/>
|
||||
</div>
|
||||
</van-cell-group>
|
||||
</template>
|
||||
|
||||
<van-cell-group v-if="!isReadOnly" inset class="section-card" title="单据状态">
|
||||
<div class="status-radio-wrap">
|
||||
@@ -214,7 +401,9 @@
|
||||
createPublicIoOrderApi,
|
||||
type BrandQtyItem,
|
||||
type PublicIoOrderItem,
|
||||
type PublicIoOrderPage
|
||||
type PublicIoOrderPage,
|
||||
type PublicIoOrderStop,
|
||||
type PublicIoOrderStopProduct
|
||||
} from '@/api/pl/public-io-order'
|
||||
import BrandQtyChipsField from '@/components/business/brand-qty-chips-field/index.vue'
|
||||
import PublicMobileShell from '@/layouts/PublicMobileShell.vue'
|
||||
@@ -232,6 +421,17 @@
|
||||
brandQtyRows: BrandQtyItem[]
|
||||
}
|
||||
|
||||
type EditableStopProduct = PublicIoOrderStopProduct & {
|
||||
actualQtyText: string
|
||||
brandQtyRows: BrandQtyItem[]
|
||||
}
|
||||
|
||||
type StopState = PublicIoOrderStop & {
|
||||
attachmentUrls: string[]
|
||||
uploaderFiles: UploaderFileListItem[]
|
||||
editableProducts: EditableStopProduct[]
|
||||
}
|
||||
|
||||
const props = defineProps<{ kind: 'inbound' | 'outbound' }>()
|
||||
const api = createPublicIoOrderApi(props.kind)
|
||||
const route = useRoute()
|
||||
@@ -249,8 +449,13 @@
|
||||
const feedbackImages = ref<string[]>([])
|
||||
const uploaderFiles = ref<UploaderFileListItem[]>([])
|
||||
const editableItems = ref<EditableIoOrderItem[]>([])
|
||||
const stopStates = ref<StopState[]>([])
|
||||
const selectedStatus = ref<IoOrderStatus>('in_progress')
|
||||
const isReadOnly = computed(() => Boolean(page.value?.voided))
|
||||
const useMultiStop = computed(() => (page.value?.stops?.length || 0) > 0)
|
||||
const hasInternalProductStops = computed(() =>
|
||||
stopStates.value.some((stop) => stop.showProductQty && stop.editableProducts.length > 0)
|
||||
)
|
||||
|
||||
const deliveryAddressDisplay = computed(() => {
|
||||
if (!page.value) return '—'
|
||||
@@ -279,6 +484,11 @@
|
||||
window.location.href = url
|
||||
}
|
||||
|
||||
function openStopNavigation(stop: StopState) {
|
||||
const url = buildStopNavUrl(stop)
|
||||
if (url) openNavigation(url)
|
||||
}
|
||||
|
||||
function formatDateTime(value?: string) {
|
||||
if (!value) return '—'
|
||||
const normalized = String(value).replace('T', ' ')
|
||||
@@ -292,7 +502,14 @@
|
||||
return unit ? `${qty} ${unit}` : String(qty)
|
||||
}
|
||||
|
||||
function formatBrandLabel(item: PublicIoOrderItem) {
|
||||
function formatStopPlanQty(item: PublicIoOrderStopProduct) {
|
||||
const qty = item.quantity
|
||||
const unit = item.unit || ''
|
||||
if (qty == null) return '—'
|
||||
return unit ? `${qty} ${unit}` : String(qty)
|
||||
}
|
||||
|
||||
function formatBrandLabel(item: PublicIoOrderItem | PublicIoOrderStopProduct) {
|
||||
return resolvePlanBrandDisplayLabel(item) || '—'
|
||||
}
|
||||
|
||||
@@ -326,8 +543,10 @@
|
||||
})) as UploaderFileListItem[]
|
||||
}
|
||||
|
||||
function mapBrandQtyRows(it: PublicIoOrderItem): BrandQtyItem[] {
|
||||
const existing = (it.brandQtys || [])
|
||||
function mapBrandQtyRows(
|
||||
prod: PublicIoOrderItem | PublicIoOrderStopProduct
|
||||
): BrandQtyItem[] {
|
||||
const existing = (prod.brandQtys || [])
|
||||
.filter((row) => Number(row.qty ?? 0) > 0)
|
||||
.map((row) => ({
|
||||
brandId: row.brandId,
|
||||
@@ -336,34 +555,51 @@
|
||||
}))
|
||||
if (existing.length) return existing
|
||||
|
||||
// 指定品牌:仅预选计划上的 brandId,禁止把总量塞到 options 第一项
|
||||
if (it.brandMode === 'required' && it.brandId) {
|
||||
if (prod.brandMode === 'required' && prod.brandId) {
|
||||
const brandName =
|
||||
it.brandName ||
|
||||
it.brandOptions?.find((o) => o.brandId === it.brandId)?.brandName ||
|
||||
prod.brandName ||
|
||||
prod.brandOptions?.find((o) => o.brandId === prod.brandId)?.brandName ||
|
||||
'指定品牌'
|
||||
const seedQty = it.actualQty != null ? Number(it.actualQty) : 0
|
||||
return [{ brandId: it.brandId, brandName, qty: seedQty }]
|
||||
const seedQty = prod.actualQty != null ? Number(prod.actualQty) : 0
|
||||
return [{ brandId: prod.brandId, brandName, qty: seedQty }]
|
||||
}
|
||||
|
||||
return []
|
||||
}
|
||||
|
||||
function brandModeForField(item: EditableIoOrderItem): 'any' | 'required' | null {
|
||||
if (item.brandMode === 'any' || item.brandMode === 'required') return item.brandMode
|
||||
return null
|
||||
}
|
||||
|
||||
function syncItemActualQty(item: EditableIoOrderItem, val: number) {
|
||||
item.actualQtyText = String(val)
|
||||
}
|
||||
|
||||
function brandQtySum(rows: BrandQtyItem[]) {
|
||||
return rows.reduce((sum, row) => sum + Number(row.qty || 0), 0)
|
||||
}
|
||||
|
||||
function validateBrandedItemsForCompleted(): string | null {
|
||||
for (const item of editableItems.value) {
|
||||
function mapStopProductRows(prod: PublicIoOrderStopProduct): EditableStopProduct {
|
||||
const brandQtyRows = mapBrandQtyRows(prod)
|
||||
return {
|
||||
...prod,
|
||||
brandOptions: prod.brandOptions || [],
|
||||
brandQtyRows,
|
||||
actualQtyText: prod.brandMode
|
||||
? String(Number(brandQtySum(brandQtyRows).toFixed(3)))
|
||||
: prod.actualQty != null
|
||||
? String(prod.actualQty)
|
||||
: ''
|
||||
}
|
||||
}
|
||||
|
||||
function brandModeForField(
|
||||
item: EditableIoOrderItem | EditableStopProduct
|
||||
): 'any' | 'required' | null {
|
||||
if (item.brandMode === 'any' || item.brandMode === 'required') return item.brandMode
|
||||
return null
|
||||
}
|
||||
|
||||
function syncItemActualQty(item: EditableIoOrderItem | EditableStopProduct, val: number) {
|
||||
item.actualQtyText = String(val)
|
||||
}
|
||||
|
||||
function validateBrandedProductRows(
|
||||
items: Array<EditableIoOrderItem | EditableStopProduct>
|
||||
): string | null {
|
||||
for (const item of items) {
|
||||
if (!item.brandMode) continue
|
||||
const positiveRows = (item.brandQtyRows || []).filter((r) => Number(r.qty) > 0)
|
||||
if (!positiveRows.length) {
|
||||
@@ -378,6 +614,83 @@
|
||||
return null
|
||||
}
|
||||
|
||||
function validateBrandedItemsForCompleted(): string | null {
|
||||
if (useMultiStop.value) {
|
||||
for (const stop of stopStates.value) {
|
||||
if (!stop.showProductQty) continue
|
||||
const err = validateBrandedProductRows(stop.editableProducts)
|
||||
if (err) return err
|
||||
}
|
||||
if (!hasInternalProductStops.value) {
|
||||
return validateBrandedProductRows(editableItems.value)
|
||||
}
|
||||
return null
|
||||
}
|
||||
return validateBrandedProductRows(editableItems.value)
|
||||
}
|
||||
|
||||
function syncStopUploader(stop: StopState) {
|
||||
stop.uploaderFiles = stop.attachmentUrls.map((url, index) => ({
|
||||
url: resolveFileUrl(url),
|
||||
isImage: /\.(png|jpe?g|gif|webp|bmp)$/i.test(url),
|
||||
name: `附件${index + 1}`,
|
||||
fileUrl: url
|
||||
})) as UploaderFileListItem[]
|
||||
}
|
||||
|
||||
function buildStopNavUrl(stop: StopState) {
|
||||
return buildAmapNavigationUrl(stop.lng ?? null, stop.lat ?? null, stop.address || stop.label)
|
||||
}
|
||||
|
||||
function buildStopProductsPayload(stop: StopState) {
|
||||
return stop.editableProducts.map((item) => ({
|
||||
stopProductId: item.stopProductId,
|
||||
actualQty: Number(item.actualQtyText || 0),
|
||||
brandQtys: item.brandMode
|
||||
? (item.brandQtyRows || [])
|
||||
.filter((row) => Number(row.qty) > 0)
|
||||
.map((row) => ({
|
||||
brandId: row.brandId,
|
||||
brandName: row.brandName,
|
||||
qty: Number(row.qty)
|
||||
}))
|
||||
: undefined
|
||||
}))
|
||||
}
|
||||
|
||||
async function handleStopAfterRead(
|
||||
stop: StopState,
|
||||
item: UploaderFileListItem | UploaderFileListItem[]
|
||||
) {
|
||||
if (isReadOnly.value) return
|
||||
const files = Array.isArray(item) ? item : [item]
|
||||
for (const fileItem of files) {
|
||||
if (!fileItem.file) continue
|
||||
fileItem.status = 'uploading'
|
||||
fileItem.message = '上传中...'
|
||||
try {
|
||||
const res = await api.uploadAttachment(token.value, fileItem.file as File)
|
||||
if (res.fileUrl) {
|
||||
stop.attachmentUrls.push(res.fileUrl)
|
||||
;(fileItem as UploaderFileListItem & { fileUrl?: string }).fileUrl = res.fileUrl
|
||||
fileItem.url = resolveFileUrl(res.fileUrl)
|
||||
fileItem.status = 'done'
|
||||
fileItem.message = ''
|
||||
}
|
||||
} catch (e: any) {
|
||||
fileItem.status = 'failed'
|
||||
fileItem.message = e?.message || '上传失败'
|
||||
showFailToast(fileItem.message)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function handleStopBeforeDelete(stop: StopState, index: number) {
|
||||
if (isReadOnly.value) return false
|
||||
stop.attachmentUrls.splice(index, 1)
|
||||
return true
|
||||
}
|
||||
|
||||
async function loadPage() {
|
||||
loading.value = true
|
||||
errorMessage.value = ''
|
||||
@@ -386,6 +699,20 @@
|
||||
page.value = data
|
||||
feedbackRemark.value = data.siteFeedbackRemark || ''
|
||||
feedbackImages.value = [...(data.siteFeedbackImages || [])]
|
||||
stopStates.value = (data.stops || []).map((stop) => {
|
||||
const showProductQty = Boolean(stop.showProductQty)
|
||||
const state: StopState = {
|
||||
...stop,
|
||||
showProductQty,
|
||||
attachmentUrls: [...(stop.attachmentUrls || [])],
|
||||
uploaderFiles: [],
|
||||
editableProducts: showProductQty
|
||||
? (stop.products || []).map(mapStopProductRows)
|
||||
: []
|
||||
}
|
||||
syncStopUploader(state)
|
||||
return state
|
||||
})
|
||||
editableItems.value = (data.items || []).map((it) => {
|
||||
const brandQtyRows = mapBrandQtyRows(it)
|
||||
return {
|
||||
@@ -467,24 +794,54 @@
|
||||
|
||||
saving.value = true
|
||||
try {
|
||||
await api.saveFeedback(token.value, {
|
||||
status: selectedStatus.value,
|
||||
remark: feedbackRemark.value,
|
||||
images: feedbackImages.value,
|
||||
items: editableItems.value.map((it) => ({
|
||||
id: it.id,
|
||||
actualQty: Number(it.actualQtyText || 0),
|
||||
brandQtys: it.brandMode
|
||||
? (it.brandQtyRows || [])
|
||||
.filter((row) => Number(row.qty) > 0)
|
||||
.map((row) => ({
|
||||
brandId: row.brandId,
|
||||
brandName: row.brandName,
|
||||
qty: Number(row.qty)
|
||||
}))
|
||||
: undefined
|
||||
}))
|
||||
})
|
||||
if (useMultiStop.value) {
|
||||
const payload: Parameters<typeof api.saveFeedback>[1] = {
|
||||
status: selectedStatus.value,
|
||||
remark: feedbackRemark.value,
|
||||
images: [],
|
||||
stops: stopStates.value.map((stop) => ({
|
||||
stopType: stop.stopType,
|
||||
stopId: stop.stopId,
|
||||
attachmentUrls: stop.attachmentUrls,
|
||||
products: stop.showProductQty ? buildStopProductsPayload(stop) : []
|
||||
}))
|
||||
}
|
||||
if (!hasInternalProductStops.value) {
|
||||
payload.items = editableItems.value.map((it) => ({
|
||||
id: it.id,
|
||||
actualQty: Number(it.actualQtyText || 0),
|
||||
brandQtys: it.brandMode
|
||||
? (it.brandQtyRows || [])
|
||||
.filter((row) => Number(row.qty) > 0)
|
||||
.map((row) => ({
|
||||
brandId: row.brandId,
|
||||
brandName: row.brandName,
|
||||
qty: Number(row.qty)
|
||||
}))
|
||||
: undefined
|
||||
}))
|
||||
}
|
||||
await api.saveFeedback(token.value, payload)
|
||||
} else {
|
||||
await api.saveFeedback(token.value, {
|
||||
status: selectedStatus.value,
|
||||
remark: feedbackRemark.value,
|
||||
images: feedbackImages.value,
|
||||
items: editableItems.value.map((it) => ({
|
||||
id: it.id,
|
||||
actualQty: Number(it.actualQtyText || 0),
|
||||
brandQtys: it.brandMode
|
||||
? (it.brandQtyRows || [])
|
||||
.filter((row) => Number(row.qty) > 0)
|
||||
.map((row) => ({
|
||||
brandId: row.brandId,
|
||||
brandName: row.brandName,
|
||||
qty: Number(row.qty)
|
||||
}))
|
||||
: undefined
|
||||
}))
|
||||
})
|
||||
}
|
||||
showSuccessToast('提交成功')
|
||||
await loadPage()
|
||||
} catch (e: any) {
|
||||
@@ -722,4 +1079,26 @@
|
||||
color: #059669;
|
||||
min-width: 24px;
|
||||
}
|
||||
|
||||
.stop-uploader-wrap {
|
||||
padding: 8px 14px 12px;
|
||||
}
|
||||
|
||||
.stop-products-wrap {
|
||||
padding: 0 4px 4px;
|
||||
}
|
||||
|
||||
.stop-products-title {
|
||||
padding: 8px 10px 4px;
|
||||
font-size: 12px;
|
||||
font-weight: 700;
|
||||
color: #334155;
|
||||
}
|
||||
|
||||
.stop-uploader-label {
|
||||
margin-bottom: 8px;
|
||||
font-size: 12px;
|
||||
font-weight: 700;
|
||||
color: #334155;
|
||||
}
|
||||
</style>
|
||||
@@ -0,0 +1,16 @@
|
||||
<template>
|
||||
<span class="stop-segment-title">
|
||||
<span class="stop-segment-title__type">{{ label }}</span>
|
||||
<span class="stop-segment-title__sep"> · </span>
|
||||
<span class="stop-segment-title__customer">{{ customerName || '—' }}</span>
|
||||
<span v-if="businessType" class="stop-segment-title__biz">({{ businessType }})</span>
|
||||
</span>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
defineProps<{
|
||||
label: string
|
||||
customerName?: string
|
||||
businessType?: string
|
||||
}>()
|
||||
</script>
|
||||
@@ -0,0 +1,435 @@
|
||||
<template>
|
||||
<PublicMobileShell>
|
||||
<div class="public-pl-history-page">
|
||||
<van-nav-bar
|
||||
title="现场记录"
|
||||
left-arrow
|
||||
:border="false"
|
||||
class="transport-nav-bar"
|
||||
@click-left="goBack"
|
||||
/>
|
||||
|
||||
<van-loading v-if="bootLoading" vertical class="page-loading">加载中...</van-loading>
|
||||
<van-empty v-else-if="fatalError" :description="fatalError" />
|
||||
<template v-else>
|
||||
<div class="filters">
|
||||
<van-calendar
|
||||
class="history-calendar"
|
||||
:poppable="false"
|
||||
:show-confirm="false"
|
||||
:show-title="false"
|
||||
:show-mark="false"
|
||||
:safe-area-inset-bottom="false"
|
||||
switch-mode="month"
|
||||
color="#059669"
|
||||
:row-height="28"
|
||||
:default-date="calendarDate"
|
||||
:min-date="minDate"
|
||||
:max-date="maxDate"
|
||||
@select="onCalendarSelect"
|
||||
/>
|
||||
<input
|
||||
v-model="keyword"
|
||||
type="search"
|
||||
class="search-input"
|
||||
placeholder="车牌号/产品名称"
|
||||
enterkeyhint="search"
|
||||
/>
|
||||
</div>
|
||||
|
||||
<van-loading v-if="loading" vertical class="list-loading">加载中...</van-loading>
|
||||
<van-empty v-else-if="!records.length" description="暂无现场记录" />
|
||||
<template v-else>
|
||||
<div
|
||||
v-for="(row, index) in records"
|
||||
:key="row.planId"
|
||||
class="record-card"
|
||||
role="button"
|
||||
@click="openRecord(row)"
|
||||
>
|
||||
<span class="index-tag">{{ index + 1 }}</span>
|
||||
<div class="record-top">
|
||||
<span class="card-title">{{ cardTitle(row) }}</span>
|
||||
<span class="tag" :class="tagClass(row)">{{ row.statusLabel || '进行中' }}</span>
|
||||
</div>
|
||||
<div class="meta">
|
||||
车牌:<span class="plate-hl">{{ row.licensePlate || '—' }}</span>
|
||||
</div>
|
||||
<template v-if="(row.stops || []).length">
|
||||
<div
|
||||
v-for="(stop, sIndex) in row.stops"
|
||||
:key="`${stop.stopType}-${stop.seq ?? sIndex}`"
|
||||
class="stop-block"
|
||||
>
|
||||
<div class="stop-block__title">{{ stop.label }} · {{ stop.customerName || '—' }}</div>
|
||||
<div class="meta">时间:{{ formatDay(stop.stopTime) }}</div>
|
||||
<div class="meta">地址:{{ stop.address || '—' }}</div>
|
||||
<template v-if="!(stop.products || []).length">
|
||||
<div class="meta">产品:—</div>
|
||||
<div class="meta">规格型号:—</div>
|
||||
<div class="meta">包装规格:—</div>
|
||||
<div class="meta">数量:— · 单位:—</div>
|
||||
</template>
|
||||
<template v-for="(prod, pIndex) in stop.products || []" :key="pIndex">
|
||||
<div class="meta">产品:{{ prod.productName || '—' }}</div>
|
||||
<div class="meta">规格型号:{{ prod.model || '—' }}</div>
|
||||
<div class="meta">包装规格:{{ prod.packageSpec || '—' }}</div>
|
||||
<div class="meta">
|
||||
数量:{{ formatQty(prod.quantity) }} · 单位:{{ prod.unit || '—' }}
|
||||
</div>
|
||||
</template>
|
||||
</div>
|
||||
</template>
|
||||
<template v-else>
|
||||
<div class="meta">
|
||||
取货:{{ formatDay(row.pickupTime) }} · 送货:{{ formatDay(row.deliveryTime) }}
|
||||
</div>
|
||||
<div class="meta">
|
||||
路线:{{ row.pickupAddress || '—' }} → {{ row.destinationAddress || '—' }}
|
||||
</div>
|
||||
<template v-if="!(row.products || []).length">
|
||||
<div class="meta">产品:—</div>
|
||||
<div class="meta">规格型号:—</div>
|
||||
<div class="meta">包装规格:—</div>
|
||||
<div class="meta">数量:— · 单位:—</div>
|
||||
</template>
|
||||
<template v-for="(prod, pIndex) in row.products || []" :key="pIndex">
|
||||
<div class="meta">产品:{{ prod.productName || '—' }}</div>
|
||||
<div class="meta">规格型号:{{ prod.model || '—' }}</div>
|
||||
<div class="meta">包装规格:{{ prod.packageSpec || '—' }}</div>
|
||||
<div class="meta">
|
||||
数量:{{ formatQty(prod.quantity) }} · 单位:{{ prod.unit || '—' }}
|
||||
</div>
|
||||
</template>
|
||||
</template>
|
||||
<div class="meta">运输计划号:{{ row.planNo || '—' }}</div>
|
||||
</div>
|
||||
</template>
|
||||
</template>
|
||||
</div>
|
||||
</PublicMobileShell>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { showFailToast } from 'vant'
|
||||
import { watchDebounced } from '@vueuse/core'
|
||||
import type { PublicTransportHistoryRecord } from '@/api/pl/public-transport'
|
||||
import { publicTransportSiteApi } from '@/api/pl/public-transport-site'
|
||||
import PublicMobileShell from '@/layouts/PublicMobileShell.vue'
|
||||
|
||||
import 'vant/es/toast/style'
|
||||
import 'vant/es/calendar/style'
|
||||
import '@/styles/public-mobile-vant.scss'
|
||||
|
||||
const route = useRoute()
|
||||
const router = useRouter()
|
||||
const token = computed(() => String(route.params.token || ''))
|
||||
|
||||
const bootLoading = ref(true)
|
||||
const loading = ref(false)
|
||||
const fatalError = ref('')
|
||||
const records = ref<PublicTransportHistoryRecord[]>([])
|
||||
const pickDate = ref(formatYmd(startOfToday()))
|
||||
const calendarDate = ref(startOfToday())
|
||||
const keyword = ref('')
|
||||
const minDate = new Date(new Date().getFullYear() - 2, 0, 1)
|
||||
const maxDate = new Date(new Date().getFullYear() + 2, 11, 31)
|
||||
|
||||
function startOfToday() {
|
||||
const d = new Date()
|
||||
d.setHours(0, 0, 0, 0)
|
||||
return d
|
||||
}
|
||||
|
||||
function formatYmd(d: Date) {
|
||||
const y = d.getFullYear()
|
||||
const m = String(d.getMonth() + 1).padStart(2, '0')
|
||||
const day = String(d.getDate()).padStart(2, '0')
|
||||
return `${y}-${m}-${day}`
|
||||
}
|
||||
|
||||
function formatDay(value?: string) {
|
||||
if (!value) return '—'
|
||||
const normalized = value.replace('T', ' ')
|
||||
return normalized.length >= 10 ? normalized.slice(0, 10) : normalized
|
||||
}
|
||||
|
||||
function formatQty(value?: number | null) {
|
||||
if (value == null) return '—'
|
||||
return String(value)
|
||||
}
|
||||
|
||||
function cardTitleDate(row: PublicTransportHistoryRecord) {
|
||||
const stopTimes = (row.stops || [])
|
||||
.map((stop) => formatDay(stop.stopTime))
|
||||
.filter((value) => value !== '—')
|
||||
if (stopTimes.length) return stopTimes[0]
|
||||
const fromPickup = formatDay(row.pickupTime)
|
||||
if (fromPickup !== '—') return fromPickup
|
||||
const fromDelivery = formatDay(row.deliveryTime)
|
||||
if (fromDelivery !== '—') return fromDelivery
|
||||
return pickDate.value
|
||||
}
|
||||
|
||||
function cardTitle(row: PublicTransportHistoryRecord) {
|
||||
const names = (row.stops || [])
|
||||
.flatMap((stop) => (stop.products || []).map((p) => (p.productName || '').trim()))
|
||||
.filter(Boolean)
|
||||
const uniqueNames = [...new Set(names)]
|
||||
const productLabel = uniqueNames.length ? uniqueNames.join('、') : '—'
|
||||
return `${cardTitleDate(row)} ${productLabel}`
|
||||
}
|
||||
|
||||
function tagClass(row: PublicTransportHistoryRecord) {
|
||||
if (row.planVoided || row.statusLabel === '已作废') return 'tag--danger'
|
||||
if (row.planArchived || row.statusLabel === '已归档') return 'tag--muted'
|
||||
return 'tag--success'
|
||||
}
|
||||
|
||||
function goBack() {
|
||||
router.push({ name: 'PublicPlTransportMultiStopSite', params: { token: token.value } })
|
||||
}
|
||||
|
||||
function onCalendarSelect(date: Date) {
|
||||
const next = formatYmd(date)
|
||||
if (next === pickDate.value) return
|
||||
pickDate.value = next
|
||||
calendarDate.value = date
|
||||
load({ silentBoot: true })
|
||||
}
|
||||
|
||||
function openRecord(row: PublicTransportHistoryRecord) {
|
||||
const accessToken = (row.siteAccessToken || '').trim()
|
||||
if (!accessToken) {
|
||||
showFailToast('该记录暂无现场链接')
|
||||
return
|
||||
}
|
||||
router.push({ name: 'PublicPlTransportMultiStopSite', params: { token: accessToken } })
|
||||
}
|
||||
|
||||
async function load(options?: { silentBoot?: boolean }) {
|
||||
loading.value = true
|
||||
if (!options?.silentBoot) {
|
||||
bootLoading.value = true
|
||||
fatalError.value = ''
|
||||
}
|
||||
try {
|
||||
const data = await publicTransportSiteApi.getHistory(
|
||||
token.value,
|
||||
pickDate.value,
|
||||
keyword.value
|
||||
)
|
||||
records.value = data?.records || []
|
||||
fatalError.value = ''
|
||||
} catch (e: any) {
|
||||
records.value = []
|
||||
if (!options?.silentBoot) {
|
||||
fatalError.value = e?.message || '链接无效或已失效'
|
||||
} else {
|
||||
showFailToast(e?.message || '加载失败')
|
||||
}
|
||||
} finally {
|
||||
loading.value = false
|
||||
bootLoading.value = false
|
||||
}
|
||||
}
|
||||
|
||||
onMounted(() => load())
|
||||
|
||||
watchDebounced(
|
||||
keyword,
|
||||
() => {
|
||||
load({ silentBoot: true })
|
||||
},
|
||||
{ debounce: 300 }
|
||||
)
|
||||
</script>
|
||||
|
||||
<style scoped lang="scss">
|
||||
.page-loading,
|
||||
.list-loading {
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
padding: 48px 0;
|
||||
}
|
||||
|
||||
.list-loading {
|
||||
padding: 32px 0;
|
||||
}
|
||||
|
||||
.transport-nav-bar {
|
||||
margin: -12px -16px 12px;
|
||||
border-radius: 0 0 12px 12px;
|
||||
overflow: hidden;
|
||||
|
||||
:deep(.van-nav-bar) {
|
||||
background: #059669;
|
||||
}
|
||||
|
||||
:deep(.van-nav-bar__title),
|
||||
:deep(.van-nav-bar__arrow) {
|
||||
color: #fff;
|
||||
}
|
||||
|
||||
:deep(.van-nav-bar__title) {
|
||||
font-weight: 600;
|
||||
}
|
||||
}
|
||||
|
||||
.filters {
|
||||
margin-bottom: 12px;
|
||||
padding: 4px 4px 10px;
|
||||
border-radius: 12px;
|
||||
background: #fff;
|
||||
border: 1px solid #e2e8f0;
|
||||
max-width: 100%;
|
||||
overflow: hidden;
|
||||
box-sizing: border-box;
|
||||
}
|
||||
|
||||
.history-calendar {
|
||||
height: auto;
|
||||
--van-calendar-background: #fff;
|
||||
--van-calendar-header-shadow: none;
|
||||
--van-calendar-header-title-height: 32px;
|
||||
--van-calendar-header-subtitle-font-size: 13px;
|
||||
--van-calendar-weekdays-height: 24px;
|
||||
--van-calendar-weekdays-font-size: 11px;
|
||||
--van-calendar-day-height: 28px;
|
||||
--van-calendar-day-font-size: 12px;
|
||||
--van-calendar-day-margin-bottom: 0;
|
||||
--van-calendar-selected-day-size: 26px;
|
||||
--van-primary-color: #059669;
|
||||
|
||||
:deep(.van-calendar__footer) {
|
||||
display: none;
|
||||
}
|
||||
|
||||
:deep(.van-calendar__body) {
|
||||
overflow: hidden;
|
||||
}
|
||||
}
|
||||
|
||||
.search-input {
|
||||
display: block;
|
||||
width: calc(100% - 8px);
|
||||
max-width: 100%;
|
||||
min-width: 0;
|
||||
height: 36px;
|
||||
margin: 8px 4px 0;
|
||||
padding: 0 12px;
|
||||
border: 1px solid #cbd5e1;
|
||||
border-radius: 8px;
|
||||
font-size: 14px;
|
||||
color: #0f172a;
|
||||
background: #fff;
|
||||
box-sizing: border-box;
|
||||
}
|
||||
|
||||
.record-card {
|
||||
position: relative;
|
||||
margin-bottom: 10px;
|
||||
padding: 16px 14px 14px;
|
||||
border-radius: 12px;
|
||||
background: #fff;
|
||||
border: 1px solid #e2e8f0;
|
||||
cursor: pointer;
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
.index-tag {
|
||||
position: absolute;
|
||||
top: 0;
|
||||
left: 0;
|
||||
min-width: 24px;
|
||||
height: 22px;
|
||||
padding: 0 8px;
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
border-radius: 12px 0 10px 0;
|
||||
background: #059669;
|
||||
color: #fff;
|
||||
font-size: 12px;
|
||||
font-weight: 700;
|
||||
line-height: 1;
|
||||
}
|
||||
|
||||
.record-top {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
gap: 8px;
|
||||
margin-bottom: 8px;
|
||||
padding-left: 4px;
|
||||
}
|
||||
|
||||
.card-title {
|
||||
font-size: 15px;
|
||||
font-weight: 700;
|
||||
color: #0f172a;
|
||||
word-break: break-all;
|
||||
}
|
||||
|
||||
.tag {
|
||||
flex-shrink: 0;
|
||||
font-size: 11px;
|
||||
font-weight: 600;
|
||||
padding: 2px 8px;
|
||||
border-radius: 999px;
|
||||
line-height: 1.4;
|
||||
}
|
||||
|
||||
.tag--success {
|
||||
background: #059669;
|
||||
color: #fff;
|
||||
}
|
||||
|
||||
.tag--danger {
|
||||
background: #dc2626;
|
||||
color: #fff;
|
||||
}
|
||||
|
||||
.tag--muted {
|
||||
background: #94a3b8;
|
||||
color: #fff;
|
||||
}
|
||||
|
||||
.meta {
|
||||
font-size: 13px;
|
||||
color: #0f172a;
|
||||
line-height: 1.45;
|
||||
word-break: break-all;
|
||||
|
||||
& + .meta {
|
||||
margin-top: 4px;
|
||||
}
|
||||
}
|
||||
|
||||
.plate-hl {
|
||||
color: #059669;
|
||||
font-weight: 700;
|
||||
font-size: 15px;
|
||||
}
|
||||
|
||||
.stop-block {
|
||||
margin-top: 10px;
|
||||
padding: 10px 10px 8px;
|
||||
border-radius: 8px;
|
||||
background: #f8fafc;
|
||||
border: 1px solid #e2e8f0;
|
||||
|
||||
& + .stop-block {
|
||||
margin-top: 8px;
|
||||
}
|
||||
}
|
||||
|
||||
.stop-block__title {
|
||||
margin-bottom: 6px;
|
||||
font-size: 13px;
|
||||
font-weight: 700;
|
||||
color: #059669;
|
||||
line-height: 1.4;
|
||||
word-break: break-all;
|
||||
}
|
||||
</style>
|
||||
@@ -0,0 +1,592 @@
|
||||
<template>
|
||||
<PublicMobileShell>
|
||||
<div class="public-pl-transport-page">
|
||||
<van-nav-bar title="现场回传" :border="false" class="transport-nav-bar" />
|
||||
|
||||
<van-loading v-if="loading" vertical class="page-loading">加载中...</van-loading>
|
||||
<van-empty v-else-if="errorMessage" :description="errorMessage" />
|
||||
<van-empty v-else-if="page?.planVoided" description="运输计划已作废" />
|
||||
<van-empty v-else-if="page?.planArchived" description="运输计划已归档完成" />
|
||||
<van-empty v-else-if="page && !page.stops.length" description="暂无需要现场回传的段" />
|
||||
<template v-else-if="page">
|
||||
<van-cell-group inset class="section-card">
|
||||
<van-cell title="计划编号" :value="page.planNo" />
|
||||
<van-cell title="计划日期" :value="page.planDate || '—'" />
|
||||
<van-cell title="车牌" :value="page.licensePlate || page.vehicleNo || '—'" />
|
||||
</van-cell-group>
|
||||
|
||||
<van-cell-group
|
||||
v-for="stop in stopStates"
|
||||
:key="`${stop.stopType}-${stop.stopId}`"
|
||||
inset
|
||||
class="section-card"
|
||||
>
|
||||
<template #title>
|
||||
<PublicPlStopSectionTitle
|
||||
:label="stop.label"
|
||||
:customer-name="stop.customerName"
|
||||
:business-type="stop.businessType"
|
||||
/>
|
||||
</template>
|
||||
<van-cell title="地址" class="address-cell multiline-cell">
|
||||
<template #value>
|
||||
<div class="address-cell__content">
|
||||
<span class="address-cell__text">{{ stop.address || '—' }}</span>
|
||||
<van-button
|
||||
v-if="buildStopNavUrl(stop)"
|
||||
size="mini"
|
||||
type="primary"
|
||||
round
|
||||
class="address-nav-btn"
|
||||
@click="openNavigation(buildStopNavUrl(stop)!)"
|
||||
>
|
||||
导航
|
||||
</van-button>
|
||||
</div>
|
||||
</template>
|
||||
</van-cell>
|
||||
<van-cell title="联系方式" :value="stop.contact || '—'" class="multiline-cell" />
|
||||
<van-cell title="注意事项" :value="stop.notes || '—'" class="multiline-cell" />
|
||||
|
||||
<div class="stop-products-wrap">
|
||||
<div v-if="stop.products?.length" class="stop-products-title">产品信息</div>
|
||||
<div
|
||||
v-for="(item, idx) in stop.products || []"
|
||||
:key="item.stopProductId"
|
||||
class="product-card"
|
||||
>
|
||||
<div class="product-card__head">
|
||||
<div class="product-card__head-main">
|
||||
<span class="product-card__badge">
|
||||
{{ idx + 1 }}/{{ stop.products!.length }}
|
||||
</span>
|
||||
<div class="product-card__name">{{ item.productName || '产品' }}</div>
|
||||
</div>
|
||||
<div class="product-card__plan">
|
||||
<span class="product-card__plan-label">计划</span>
|
||||
<strong>{{ formatPlanQty(item) }}</strong>
|
||||
</div>
|
||||
</div>
|
||||
<div class="meta-list">
|
||||
<div class="meta-row">
|
||||
<span class="meta-row__label">别名</span>
|
||||
<span class="meta-row__value">{{ item.aliasName || '—' }}</span>
|
||||
</div>
|
||||
<div class="meta-row">
|
||||
<span class="meta-row__label">品牌</span>
|
||||
<span class="meta-row__value">{{ formatBrandLabel(item) }}</span>
|
||||
</div>
|
||||
<div class="meta-row">
|
||||
<span class="meta-row__label">规格型号</span>
|
||||
<span class="meta-row__value">{{ item.model || '—' }}</span>
|
||||
</div>
|
||||
<div class="meta-row">
|
||||
<span class="meta-row__label">包装规格</span>
|
||||
<span class="meta-row__value">{{ item.packageSpec || '—' }}</span>
|
||||
</div>
|
||||
<div v-if="item.remark" class="meta-row meta-row--span">
|
||||
<span class="meta-row__label">备注</span>
|
||||
<span class="meta-row__value">{{ item.remark }}</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="stop-qty-box">
|
||||
<div class="actual-box">
|
||||
<div class="actual-box__label">
|
||||
<strong>实际数量</strong>
|
||||
<span v-if="stop.planQty != null && !(stop.products || []).length">
|
||||
计划 {{ stop.planQty }} 吨
|
||||
</span>
|
||||
<span v-else>请先填写数量</span>
|
||||
</div>
|
||||
<div class="actual-box__row">
|
||||
<van-field
|
||||
v-model="stop.quantityText"
|
||||
type="number"
|
||||
class="actual-box__field"
|
||||
placeholder="请输入"
|
||||
:border="false"
|
||||
/>
|
||||
<span class="actual-box__unit">吨</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="stop-uploader-wrap">
|
||||
<div class="stop-uploader-label">附件上传</div>
|
||||
<van-uploader
|
||||
v-model="stop.uploaderFiles"
|
||||
multiple
|
||||
:max-count="9"
|
||||
:after-read="(item) => handleStopAfterRead(stop, item)"
|
||||
:before-delete="(_file, detail) => handleStopBeforeDelete(stop, detail.index)"
|
||||
accept="image/*,.pdf"
|
||||
/>
|
||||
<p v-if="!canUploadAttachments(stop)" class="uploader-tip">
|
||||
请先填写数量后再上传附件
|
||||
</p>
|
||||
</div>
|
||||
|
||||
<van-field
|
||||
v-model="stop.remark"
|
||||
rows="2"
|
||||
autosize
|
||||
type="textarea"
|
||||
maxlength="500"
|
||||
show-word-limit
|
||||
placeholder="填写备注(可选)"
|
||||
/>
|
||||
</van-cell-group>
|
||||
</template>
|
||||
|
||||
<footer v-if="page && !errorMessage && !loading" class="page-footer">
|
||||
<div v-if="page.stops.length && !page.planVoided && !page.planArchived" class="btn-row">
|
||||
<van-button block round type="primary" class="history-btn" @click="goHistory">
|
||||
现场记录
|
||||
</van-button>
|
||||
<van-button type="primary" block round :loading="saving" @click="handleSave">
|
||||
保存回传
|
||||
</van-button>
|
||||
</div>
|
||||
<van-button
|
||||
v-else
|
||||
block
|
||||
round
|
||||
type="primary"
|
||||
class="history-btn"
|
||||
@click="goHistory"
|
||||
>
|
||||
现场记录
|
||||
</van-button>
|
||||
</footer>
|
||||
</div>
|
||||
</PublicMobileShell>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import type { UploaderFileListItem } from 'vant'
|
||||
import { showFailToast, showSuccessToast } from 'vant'
|
||||
import {
|
||||
publicTransportSiteApi,
|
||||
type PublicTransportSitePage
|
||||
} from '@/api/pl/public-transport-site'
|
||||
import type { PublicTransportStop, PublicTransportStopProduct } from '@/api/pl/public-transport'
|
||||
import PublicMobileShell from '@/layouts/PublicMobileShell.vue'
|
||||
import PublicPlStopSectionTitle from '@/views/public/pl/_shared/PublicPlStopSectionTitle.vue'
|
||||
import { buildAmapNavigationUrlWithFallback } from '@/utils/amap/navigation'
|
||||
import { resolvePlanBrandDisplayLabel } from '@/utils/pl-display'
|
||||
|
||||
import 'vant/es/toast/style'
|
||||
import '@/styles/public-mobile-vant.scss'
|
||||
|
||||
type StopState = PublicTransportStop & {
|
||||
quantityText: string
|
||||
remark: string
|
||||
attachmentUrls: string[]
|
||||
uploaderFiles: UploaderFileListItem[]
|
||||
}
|
||||
|
||||
const route = useRoute()
|
||||
const router = useRouter()
|
||||
const token = computed(() => String(route.params.token || ''))
|
||||
|
||||
function goHistory() {
|
||||
router.push({ name: 'PublicPlTransportMultiStopSiteHistory', params: { token: token.value } })
|
||||
}
|
||||
|
||||
const loading = ref(true)
|
||||
const saving = ref(false)
|
||||
const errorMessage = ref('')
|
||||
const page = ref<PublicTransportSitePage | null>(null)
|
||||
const stopStates = ref<StopState[]>([])
|
||||
|
||||
function formatPlanQty(item: PublicTransportStopProduct) {
|
||||
const qty = item.quantity
|
||||
const unit = item.unit || ''
|
||||
if (qty == null) return '—'
|
||||
return unit ? `${qty} ${unit}` : String(qty)
|
||||
}
|
||||
|
||||
function formatBrandLabel(item: PublicTransportStopProduct) {
|
||||
return resolvePlanBrandDisplayLabel(item) || '—'
|
||||
}
|
||||
|
||||
function buildStopNavUrl(stop: StopState) {
|
||||
return buildAmapNavigationUrlWithFallback({
|
||||
lng: stop.lng ?? null,
|
||||
lat: stop.lat ?? null,
|
||||
address: stop.address || undefined,
|
||||
name: stop.label
|
||||
})
|
||||
}
|
||||
|
||||
function openNavigation(url: string) {
|
||||
window.location.href = url
|
||||
}
|
||||
|
||||
function resolveFileUrl(url: string) {
|
||||
if (!url) return ''
|
||||
if (/^https?:\/\//i.test(url)) return url
|
||||
const base = (import.meta.env.VITE_MINIO_BASE_URL || '').replace(/\/$/, '')
|
||||
return base ? `${base}/${url.replace(/^\//, '')}` : url
|
||||
}
|
||||
|
||||
function syncStopUploader(stop: StopState) {
|
||||
stop.uploaderFiles = stop.attachmentUrls.map((url, index) => ({
|
||||
url: resolveFileUrl(url),
|
||||
isImage: /\.(png|jpe?g|gif|webp|bmp)$/i.test(url),
|
||||
name: `附件${index + 1}`,
|
||||
fileUrl: url
|
||||
})) as UploaderFileListItem[]
|
||||
}
|
||||
|
||||
function canUploadAttachments(stop: StopState) {
|
||||
return Number(stop.quantityText || 0) > 0
|
||||
}
|
||||
|
||||
async function handleStopAfterRead(
|
||||
stop: StopState,
|
||||
item: UploaderFileListItem | UploaderFileListItem[]
|
||||
) {
|
||||
if (!canUploadAttachments(stop)) {
|
||||
showFailToast('请先填写数量后再上传附件')
|
||||
stop.uploaderFiles = []
|
||||
return
|
||||
}
|
||||
const files = Array.isArray(item) ? item : [item]
|
||||
for (const fileItem of files) {
|
||||
if (!fileItem.file) continue
|
||||
fileItem.status = 'uploading'
|
||||
fileItem.message = '上传中...'
|
||||
try {
|
||||
const res = await publicTransportSiteApi.uploadAttachment(token.value, fileItem.file as File)
|
||||
if (res.fileUrl) {
|
||||
stop.attachmentUrls.push(res.fileUrl)
|
||||
;(fileItem as UploaderFileListItem & { fileUrl?: string }).fileUrl = res.fileUrl
|
||||
fileItem.url = resolveFileUrl(res.fileUrl)
|
||||
fileItem.status = 'done'
|
||||
fileItem.message = ''
|
||||
}
|
||||
} catch (e: any) {
|
||||
fileItem.status = 'failed'
|
||||
fileItem.message = e?.message || '上传失败'
|
||||
showFailToast(fileItem.message)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function handleStopBeforeDelete(stop: StopState, index: number) {
|
||||
stop.attachmentUrls.splice(index, 1)
|
||||
return true
|
||||
}
|
||||
|
||||
async function loadPage() {
|
||||
loading.value = true
|
||||
errorMessage.value = ''
|
||||
try {
|
||||
const data = await publicTransportSiteApi.getPage(token.value)
|
||||
page.value = data
|
||||
stopStates.value = (data.stops || []).map((stop) => {
|
||||
const state: StopState = {
|
||||
...stop,
|
||||
quantityText: stop.quantity != null ? String(stop.quantity) : '',
|
||||
remark: stop.remark || '',
|
||||
attachmentUrls: [...(stop.attachmentUrls || [])],
|
||||
uploaderFiles: []
|
||||
}
|
||||
syncStopUploader(state)
|
||||
return state
|
||||
})
|
||||
} catch (e: any) {
|
||||
errorMessage.value = e?.message || '链接无效或已失效'
|
||||
page.value = null
|
||||
stopStates.value = []
|
||||
} finally {
|
||||
loading.value = false
|
||||
}
|
||||
}
|
||||
|
||||
async function handleSave() {
|
||||
if (!stopStates.value.length) return
|
||||
saving.value = true
|
||||
try {
|
||||
for (const stop of stopStates.value) {
|
||||
const quantity = Number(stop.quantityText || 0)
|
||||
if (quantity <= 0 && !stop.attachmentUrls.length && !stop.remark.trim()) {
|
||||
continue
|
||||
}
|
||||
await publicTransportSiteApi.saveFeedback(token.value, {
|
||||
stopType: stop.stopType,
|
||||
stopId: stop.stopId,
|
||||
quantity: quantity > 0 ? quantity : undefined,
|
||||
attachmentUrls: stop.attachmentUrls,
|
||||
remark: stop.remark.trim() || undefined
|
||||
})
|
||||
}
|
||||
showSuccessToast('保存成功')
|
||||
await loadPage()
|
||||
} catch (e: any) {
|
||||
showFailToast(e?.message || '保存失败')
|
||||
} finally {
|
||||
saving.value = false
|
||||
}
|
||||
}
|
||||
|
||||
onMounted(loadPage)
|
||||
</script>
|
||||
|
||||
<style scoped lang="scss">
|
||||
.page-loading {
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
padding: 48px 0;
|
||||
}
|
||||
|
||||
.transport-nav-bar {
|
||||
margin: -12px -16px 12px;
|
||||
border-radius: 0 0 12px 12px;
|
||||
overflow: hidden;
|
||||
|
||||
:deep(.van-nav-bar) {
|
||||
background: #059669;
|
||||
}
|
||||
|
||||
:deep(.van-nav-bar__title) {
|
||||
color: #fff;
|
||||
font-weight: 600;
|
||||
}
|
||||
}
|
||||
|
||||
.section-card {
|
||||
margin-bottom: 10px;
|
||||
}
|
||||
|
||||
.multiline-cell :deep(.van-cell__value) {
|
||||
line-height: 1.35;
|
||||
white-space: normal;
|
||||
}
|
||||
|
||||
.address-cell__content {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
align-items: center;
|
||||
gap: 4px 8px;
|
||||
justify-content: flex-start;
|
||||
}
|
||||
|
||||
.address-cell__text {
|
||||
line-height: 1.35;
|
||||
color: #1e293b;
|
||||
font-weight: 600;
|
||||
}
|
||||
|
||||
.address-nav-btn {
|
||||
flex-shrink: 0;
|
||||
height: 22px;
|
||||
padding: 0 8px;
|
||||
font-size: 11px;
|
||||
line-height: 22px;
|
||||
}
|
||||
|
||||
.product-card {
|
||||
margin: 8px 10px;
|
||||
padding: 10px 12px;
|
||||
border-radius: 10px;
|
||||
background: #fff;
|
||||
border: 1px solid #d1fae5;
|
||||
box-shadow: 0 1px 0 rgb(5 150 105 / 6%);
|
||||
}
|
||||
|
||||
.product-card__head {
|
||||
display: flex;
|
||||
align-items: flex-start;
|
||||
justify-content: space-between;
|
||||
gap: 8px;
|
||||
margin-bottom: 6px;
|
||||
padding-bottom: 6px;
|
||||
border-bottom: 1px dashed #e2e8f0;
|
||||
}
|
||||
|
||||
.product-card__head-main {
|
||||
display: flex;
|
||||
align-items: flex-start;
|
||||
gap: 6px;
|
||||
min-width: 0;
|
||||
flex: 1;
|
||||
}
|
||||
|
||||
.product-card__name {
|
||||
font-size: 14px;
|
||||
font-weight: 700;
|
||||
color: #0f172a;
|
||||
line-height: 1.3;
|
||||
word-break: break-all;
|
||||
}
|
||||
|
||||
.product-card__badge {
|
||||
flex-shrink: 0;
|
||||
margin-top: 1px;
|
||||
font-size: 10px;
|
||||
font-weight: 700;
|
||||
padding: 1px 6px;
|
||||
border-radius: 999px;
|
||||
background: #ecfdf5;
|
||||
color: #047857;
|
||||
line-height: 1.4;
|
||||
}
|
||||
|
||||
.product-card__plan {
|
||||
flex-shrink: 0;
|
||||
text-align: right;
|
||||
line-height: 1.2;
|
||||
|
||||
strong {
|
||||
display: block;
|
||||
font-size: 14px;
|
||||
font-weight: 700;
|
||||
color: #059669;
|
||||
}
|
||||
}
|
||||
|
||||
.product-card__plan-label {
|
||||
display: block;
|
||||
font-size: 10px;
|
||||
color: #94a3b8;
|
||||
margin-bottom: 1px;
|
||||
}
|
||||
|
||||
.meta-list {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(4, minmax(0, 1fr));
|
||||
gap: 4px 6px;
|
||||
margin-bottom: 8px;
|
||||
}
|
||||
|
||||
.meta-row {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 1px;
|
||||
min-width: 0;
|
||||
line-height: 1.3;
|
||||
}
|
||||
|
||||
.meta-row--span {
|
||||
grid-column: 1 / -1;
|
||||
}
|
||||
|
||||
.meta-row__label {
|
||||
flex-shrink: 0;
|
||||
font-size: 10px;
|
||||
color: #94a3b8;
|
||||
}
|
||||
|
||||
.meta-row__value {
|
||||
min-width: 0;
|
||||
font-size: 12px;
|
||||
font-weight: 600;
|
||||
color: #334155;
|
||||
word-break: break-all;
|
||||
}
|
||||
|
||||
.stop-qty-box {
|
||||
margin: 0 10px 8px;
|
||||
}
|
||||
|
||||
.actual-box {
|
||||
background: #f0fdf4;
|
||||
border: 1px solid #a7f3d0;
|
||||
border-radius: 8px;
|
||||
padding: 8px 10px;
|
||||
}
|
||||
|
||||
.actual-box__label {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
gap: 8px;
|
||||
margin-bottom: 6px;
|
||||
font-size: 11px;
|
||||
color: #64748b;
|
||||
|
||||
strong {
|
||||
color: #1e293b;
|
||||
font-size: 12px;
|
||||
}
|
||||
}
|
||||
|
||||
.actual-box__row {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 6px;
|
||||
}
|
||||
|
||||
.actual-box__field {
|
||||
flex: 1;
|
||||
padding: 0;
|
||||
background: #fff;
|
||||
border: 1.5px solid #6ee7b7;
|
||||
border-radius: 8px;
|
||||
overflow: hidden;
|
||||
|
||||
:deep(.van-field__control) {
|
||||
height: 34px;
|
||||
padding: 0 10px;
|
||||
font-size: 16px;
|
||||
font-weight: 700;
|
||||
color: #059669;
|
||||
line-height: 34px;
|
||||
}
|
||||
}
|
||||
|
||||
.actual-box__unit {
|
||||
flex-shrink: 0;
|
||||
font-size: 13px;
|
||||
font-weight: 700;
|
||||
color: #059669;
|
||||
min-width: 24px;
|
||||
}
|
||||
|
||||
.page-footer {
|
||||
padding: 16px;
|
||||
}
|
||||
|
||||
.btn-row {
|
||||
display: grid;
|
||||
grid-template-columns: 1fr 1fr;
|
||||
gap: 8px;
|
||||
}
|
||||
|
||||
.history-btn {
|
||||
color: #fff !important;
|
||||
}
|
||||
|
||||
.stop-uploader-wrap {
|
||||
padding: 8px 16px 12px;
|
||||
}
|
||||
|
||||
.stop-products-wrap {
|
||||
padding: 0 0 4px;
|
||||
}
|
||||
|
||||
.stop-products-title {
|
||||
margin: 0 16px 6px;
|
||||
font-size: 13px;
|
||||
font-weight: 600;
|
||||
color: #64748b;
|
||||
}
|
||||
|
||||
.stop-uploader-label {
|
||||
margin-bottom: 8px;
|
||||
font-size: 13px;
|
||||
font-weight: 500;
|
||||
color: #64748b;
|
||||
}
|
||||
|
||||
.uploader-tip {
|
||||
margin: 8px 0 0;
|
||||
font-size: 12px;
|
||||
color: #d97706;
|
||||
}
|
||||
</style>
|
||||
@@ -48,26 +48,53 @@
|
||||
<div class="meta">
|
||||
车牌:<span class="plate-hl">{{ row.licensePlate || '—' }}</span>
|
||||
</div>
|
||||
<div class="meta">
|
||||
取货:{{ formatDay(row.pickupTime) }} · 送货:{{ formatDay(row.deliveryTime) }}
|
||||
</div>
|
||||
<div class="meta">
|
||||
路线:{{ row.pickupAddress || '—' }} → {{ row.destinationAddress || '—' }}
|
||||
</div>
|
||||
<template v-if="!(row.products || []).length">
|
||||
<div class="meta">产品:—</div>
|
||||
<div class="meta">规格型号:—</div>
|
||||
<div class="meta">包装规格:—</div>
|
||||
<div class="meta">数量:— · 单位:—</div>
|
||||
</template>
|
||||
<template v-for="(prod, pIndex) in row.products || []" :key="pIndex">
|
||||
<div class="meta">产品:{{ prod.productName || '—' }}</div>
|
||||
<div class="meta">规格型号:{{ prod.model || '—' }}</div>
|
||||
<div class="meta">包装规格:{{ prod.packageSpec || '—' }}</div>
|
||||
<div class="meta">
|
||||
数量:{{ formatQty(prod.quantity) }} · 单位:{{ prod.unit || '—' }}
|
||||
<template v-if="(row.stops || []).length">
|
||||
<div
|
||||
v-for="(stop, sIndex) in row.stops"
|
||||
:key="`${stop.stopType}-${stop.seq ?? sIndex}`"
|
||||
class="stop-block"
|
||||
>
|
||||
<div class="stop-block__title">{{ stop.label }} · {{ stop.customerName || '—' }}</div>
|
||||
<div class="meta">时间:{{ formatDay(stop.stopTime) }}</div>
|
||||
<div class="meta">地址:{{ stop.address || '—' }}</div>
|
||||
<template v-if="!(stop.products || []).length">
|
||||
<div class="meta">产品:—</div>
|
||||
<div class="meta">规格型号:—</div>
|
||||
<div class="meta">包装规格:—</div>
|
||||
<div class="meta">数量:— · 单位:—</div>
|
||||
</template>
|
||||
<template v-for="(prod, pIndex) in stop.products || []" :key="pIndex">
|
||||
<div class="meta">产品:{{ prod.productName || '—' }}</div>
|
||||
<div class="meta">规格型号:{{ prod.model || '—' }}</div>
|
||||
<div class="meta">包装规格:{{ prod.packageSpec || '—' }}</div>
|
||||
<div class="meta">
|
||||
数量:{{ formatQty(prod.quantity) }} · 单位:{{ prod.unit || '—' }}
|
||||
</div>
|
||||
</template>
|
||||
</div>
|
||||
</template>
|
||||
<template v-else>
|
||||
<div class="meta">
|
||||
取货:{{ formatDay(row.pickupTime) }} · 送货:{{ formatDay(row.deliveryTime) }}
|
||||
</div>
|
||||
<div class="meta">
|
||||
路线:{{ row.pickupAddress || '—' }} → {{ row.destinationAddress || '—' }}
|
||||
</div>
|
||||
<template v-if="!(row.products || []).length">
|
||||
<div class="meta">产品:—</div>
|
||||
<div class="meta">规格型号:—</div>
|
||||
<div class="meta">包装规格:—</div>
|
||||
<div class="meta">数量:— · 单位:—</div>
|
||||
</template>
|
||||
<template v-for="(prod, pIndex) in row.products || []" :key="pIndex">
|
||||
<div class="meta">产品:{{ prod.productName || '—' }}</div>
|
||||
<div class="meta">规格型号:{{ prod.model || '—' }}</div>
|
||||
<div class="meta">包装规格:{{ prod.packageSpec || '—' }}</div>
|
||||
<div class="meta">
|
||||
数量:{{ formatQty(prod.quantity) }} · 单位:{{ prod.unit || '—' }}
|
||||
</div>
|
||||
</template>
|
||||
</template>
|
||||
<div class="meta">运输计划号:{{ row.planNo || '—' }}</div>
|
||||
</div>
|
||||
</template>
|
||||
@@ -126,6 +153,10 @@
|
||||
}
|
||||
|
||||
function cardTitleDate(row: PublicTransportHistoryRecord) {
|
||||
const stopTimes = (row.stops || [])
|
||||
.map((stop) => formatDay(stop.stopTime))
|
||||
.filter((value) => value !== '—')
|
||||
if (stopTimes.length) return stopTimes[0]
|
||||
const fromPickup = formatDay(row.pickupTime)
|
||||
if (fromPickup !== '—') return fromPickup
|
||||
const fromDelivery = formatDay(row.deliveryTime)
|
||||
@@ -134,11 +165,7 @@
|
||||
}
|
||||
|
||||
function cardTitle(row: PublicTransportHistoryRecord) {
|
||||
const names = (row.products || [])
|
||||
.map((p) => (p.productName || '').trim())
|
||||
.filter(Boolean)
|
||||
const productLabel = names.length ? names.join('、') : '—'
|
||||
return `${cardTitleDate(row)} ${productLabel}`
|
||||
return cardTitleDate(row)
|
||||
}
|
||||
|
||||
function tagClass(row: PublicTransportHistoryRecord) {
|
||||
@@ -344,4 +371,25 @@
|
||||
font-weight: 700;
|
||||
font-size: 15px;
|
||||
}
|
||||
|
||||
.stop-block {
|
||||
margin-top: 10px;
|
||||
padding: 10px 10px 8px;
|
||||
border-radius: 8px;
|
||||
background: #f8fafc;
|
||||
border: 1px solid #e2e8f0;
|
||||
|
||||
& + .stop-block {
|
||||
margin-top: 8px;
|
||||
}
|
||||
}
|
||||
|
||||
.stop-block__title {
|
||||
margin-bottom: 6px;
|
||||
font-size: 13px;
|
||||
font-weight: 700;
|
||||
color: #059669;
|
||||
line-height: 1.4;
|
||||
word-break: break-all;
|
||||
}
|
||||
</style>
|
||||
@@ -28,6 +28,123 @@
|
||||
/>
|
||||
</van-cell-group>
|
||||
|
||||
<template v-if="useMultiStop">
|
||||
<van-cell-group
|
||||
v-for="stop in stopStates"
|
||||
:key="`${stop.stopType}-${stop.stopId}`"
|
||||
inset
|
||||
class="section-card"
|
||||
>
|
||||
<template #title>
|
||||
<PublicPlStopSectionTitle :label="stop.label" :customer-name="stop.customerName" />
|
||||
</template>
|
||||
<van-cell title="地址" class="address-cell multiline-cell">
|
||||
<template #value>
|
||||
<div class="address-cell__content">
|
||||
<span class="address-cell__text">{{ stop.address || '—' }}</span>
|
||||
<van-button
|
||||
v-if="buildStopNavUrl(stop)"
|
||||
size="mini"
|
||||
type="primary"
|
||||
round
|
||||
class="address-nav-btn"
|
||||
@click="openNavigation(buildStopNavUrl(stop)!)"
|
||||
>
|
||||
导航
|
||||
</van-button>
|
||||
</div>
|
||||
</template>
|
||||
</van-cell>
|
||||
<van-cell title="联系方式" :value="stop.contact || '—'" class="multiline-cell" />
|
||||
<van-cell title="注意事项" :value="stop.notes || '—'" class="multiline-cell" />
|
||||
<div v-if="stop.editableProducts.length" class="stop-products-wrap">
|
||||
<div class="stop-products-title">
|
||||
{{ DRIVER_QTY_FEEDBACK_VISIBLE ? '产品回传数量' : '产品信息' }}
|
||||
</div>
|
||||
<div
|
||||
v-for="(item, idx) in stop.editableProducts"
|
||||
:key="item.stopProductId"
|
||||
class="product-card"
|
||||
>
|
||||
<div class="product-card__head">
|
||||
<div class="product-card__head-main">
|
||||
<span class="product-card__badge">
|
||||
{{ idx + 1 }}/{{ stop.editableProducts.length }}
|
||||
</span>
|
||||
<div class="product-card__name">{{ item.productName || '产品' }}</div>
|
||||
</div>
|
||||
<div class="product-card__plan">
|
||||
<span class="product-card__plan-label">计划</span>
|
||||
<strong>{{ formatPlanQty(item) }}</strong>
|
||||
</div>
|
||||
</div>
|
||||
<div class="meta-list">
|
||||
<div class="meta-row">
|
||||
<span class="meta-row__label">别名</span>
|
||||
<span class="meta-row__value">{{ item.aliasName || '—' }}</span>
|
||||
</div>
|
||||
<div class="meta-row">
|
||||
<span class="meta-row__label">品牌</span>
|
||||
<span class="meta-row__value">{{ formatBrandLabel(item) }}</span>
|
||||
</div>
|
||||
<div class="meta-row">
|
||||
<span class="meta-row__label">规格型号</span>
|
||||
<span class="meta-row__value">{{ item.model || '—' }}</span>
|
||||
</div>
|
||||
<div class="meta-row">
|
||||
<span class="meta-row__label">包装规格</span>
|
||||
<span class="meta-row__value">{{ item.packageSpec || '—' }}</span>
|
||||
</div>
|
||||
<div v-if="item.remark" class="meta-row meta-row--span">
|
||||
<span class="meta-row__label">备注</span>
|
||||
<span class="meta-row__value">{{ item.remark }}</span>
|
||||
</div>
|
||||
</div>
|
||||
<div v-if="DRIVER_QTY_FEEDBACK_VISIBLE" class="actual-box">
|
||||
<div class="actual-box__label">
|
||||
<strong>实际数量</strong>
|
||||
<span v-if="item.brandMode">由品牌明细合计</span>
|
||||
<span v-else>请按实装填写</span>
|
||||
</div>
|
||||
<div class="actual-box__row">
|
||||
<van-field
|
||||
v-model="item.actualQtyText"
|
||||
type="number"
|
||||
class="actual-box__field"
|
||||
placeholder="请输入"
|
||||
:border="false"
|
||||
:readonly="Boolean(item.brandMode)"
|
||||
/>
|
||||
<span class="actual-box__unit">{{ item.unit || '吨' }}</span>
|
||||
</div>
|
||||
<BrandQtyChipsField
|
||||
v-if="item.brandMode"
|
||||
v-model="item.brandQtyRows"
|
||||
:brand-mode="brandModeForField(item)"
|
||||
:required-brand-id="item.brandId"
|
||||
:brand-options="item.brandOptions || []"
|
||||
:unit="item.unit || '吨'"
|
||||
variant="mobile"
|
||||
:actual-qty="Number(item.actualQtyText || 0)"
|
||||
@update:actual-qty="(val) => syncItemActualQty(item, val)"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="stop-uploader-wrap">
|
||||
<div class="stop-uploader-label">附件上传</div>
|
||||
<van-uploader
|
||||
v-model="stop.uploaderFiles"
|
||||
multiple
|
||||
:max-count="9"
|
||||
:after-read="(item) => handleStopAfterRead(stop, item)"
|
||||
:before-delete="(_file, detail) => handleStopBeforeDelete(stop, detail.index)"
|
||||
accept="image/*,.pdf"
|
||||
/>
|
||||
</div>
|
||||
</van-cell-group>
|
||||
</template>
|
||||
<template v-else>
|
||||
<van-cell-group inset class="section-card" title="取货信息">
|
||||
<van-cell title="取货地址" class="address-cell multiline-cell">
|
||||
<template #value>
|
||||
@@ -89,12 +206,13 @@
|
||||
class="multiline-cell"
|
||||
/>
|
||||
</van-cell-group>
|
||||
</template>
|
||||
|
||||
<van-cell-group
|
||||
v-if="editableProducts.length"
|
||||
v-if="!useMultiStop && editableProducts.length"
|
||||
inset
|
||||
class="section-card"
|
||||
title="产品回传数量"
|
||||
:title="DRIVER_QTY_FEEDBACK_VISIBLE ? '产品回传数量' : '产品信息'"
|
||||
>
|
||||
<div
|
||||
v-for="(item, idx) in editableProducts"
|
||||
@@ -135,7 +253,7 @@
|
||||
<span class="meta-row__value">{{ item.remark }}</span>
|
||||
</div>
|
||||
</div>
|
||||
<div class="actual-box">
|
||||
<div v-if="DRIVER_QTY_FEEDBACK_VISIBLE" class="actual-box">
|
||||
<div class="actual-box__label">
|
||||
<strong>实际数量</strong>
|
||||
<span v-if="item.brandMode">由品牌明细合计</span>
|
||||
@@ -165,13 +283,13 @@
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
<div v-if="editableProducts.length > 1" class="total-box">
|
||||
<div v-if="DRIVER_QTY_FEEDBACK_VISIBLE && editableProducts.length > 1" class="total-box">
|
||||
<span class="total-box__label">合计回传</span>
|
||||
<span class="total-box__value">{{ totalFeedbackQty }}</span>
|
||||
</div>
|
||||
</van-cell-group>
|
||||
|
||||
<van-cell-group inset class="section-card" title="回执上传">
|
||||
<van-cell-group v-if="!useMultiStop" inset class="section-card" title="回执上传">
|
||||
<div class="uploader-wrap">
|
||||
<van-uploader
|
||||
v-model="uploaderFiles"
|
||||
@@ -233,21 +351,40 @@
|
||||
type BrandQtyItem,
|
||||
type PublicTransportPage,
|
||||
type PublicTransportPersonnel,
|
||||
type PublicTransportProduct
|
||||
type PublicTransportProduct,
|
||||
type PublicTransportStop,
|
||||
type PublicTransportStopProduct
|
||||
} from '@/api/pl/public-transport'
|
||||
import BrandQtyChipsField from '@/components/business/brand-qty-chips-field/index.vue'
|
||||
import PublicMobileShell from '@/layouts/PublicMobileShell.vue'
|
||||
import { buildAmapNavigationUrl } from '@/utils/amap/navigation'
|
||||
import PublicPlStopSectionTitle from '@/views/public/pl/_shared/PublicPlStopSectionTitle.vue'
|
||||
import {
|
||||
buildAmapNavigationUrlWithFallback
|
||||
} from '@/utils/amap/navigation'
|
||||
import { formatPlPersonnelNameWithRole, resolvePlanBrandDisplayLabel } from '@/utils/pl-display'
|
||||
|
||||
import 'vant/es/toast/style'
|
||||
import '@/styles/public-mobile-vant.scss'
|
||||
|
||||
/** 司机链接是否展示各段产品回传数量(暂时关闭,保留模板与提交逻辑) */
|
||||
const DRIVER_QTY_FEEDBACK_VISIBLE = false
|
||||
|
||||
type EditableTransportProduct = PublicTransportProduct & {
|
||||
actualQtyText: string
|
||||
brandQtyRows: BrandQtyItem[]
|
||||
}
|
||||
|
||||
type EditableStopProduct = PublicTransportStopProduct & {
|
||||
actualQtyText: string
|
||||
brandQtyRows: BrandQtyItem[]
|
||||
}
|
||||
|
||||
type StopState = PublicTransportStop & {
|
||||
attachmentUrls: string[]
|
||||
uploaderFiles: UploaderFileListItem[]
|
||||
editableProducts: EditableStopProduct[]
|
||||
}
|
||||
|
||||
const route = useRoute()
|
||||
const router = useRouter()
|
||||
const token = computed(() => String(route.params.token || ''))
|
||||
@@ -264,6 +401,9 @@
|
||||
const feedbackImages = ref<string[]>([])
|
||||
const uploaderFiles = ref<UploaderFileListItem[]>([])
|
||||
const editableProducts = ref<EditableTransportProduct[]>([])
|
||||
const stopStates = ref<StopState[]>([])
|
||||
|
||||
const useMultiStop = computed(() => (page.value?.stops?.length || 0) > 0)
|
||||
|
||||
const totalFeedbackQty = computed(() => {
|
||||
const sum = editableProducts.value.reduce(
|
||||
@@ -303,20 +443,22 @@
|
||||
|
||||
const pickupNavUrl = computed(() => {
|
||||
if (!page.value) return null
|
||||
return buildAmapNavigationUrl(
|
||||
page.value.pickupLng,
|
||||
page.value.pickupLat,
|
||||
page.value.pickupAddress || '取货点'
|
||||
)
|
||||
return buildAmapNavigationUrlWithFallback({
|
||||
lng: page.value.pickupLng,
|
||||
lat: page.value.pickupLat,
|
||||
address: page.value.pickupAddress || undefined,
|
||||
name: '取货点'
|
||||
})
|
||||
})
|
||||
|
||||
const destinationNavUrl = computed(() => {
|
||||
if (!page.value) return null
|
||||
return buildAmapNavigationUrl(
|
||||
page.value.destinationLng,
|
||||
page.value.destinationLat,
|
||||
page.value.destinationAddress || page.value.destinationName || '送货点'
|
||||
)
|
||||
return buildAmapNavigationUrlWithFallback({
|
||||
lng: page.value.destinationLng,
|
||||
lat: page.value.destinationLat,
|
||||
address: page.value.destinationAddress || page.value.destinationName || undefined,
|
||||
name: '送货点'
|
||||
})
|
||||
})
|
||||
|
||||
function openNavigation(url: string) {
|
||||
@@ -329,34 +471,34 @@
|
||||
return normalized.length > 16 ? normalized.slice(0, 16) : normalized
|
||||
}
|
||||
|
||||
function formatPlanQty(item: PublicTransportProduct) {
|
||||
function formatPlanQty(item: PublicTransportProduct | PublicTransportStopProduct) {
|
||||
const qty = item.quantity
|
||||
const unit = item.unit || ''
|
||||
if (qty == null) return '—'
|
||||
return unit ? `${qty} ${unit}` : String(qty)
|
||||
}
|
||||
|
||||
function formatBrandLabel(item: PublicTransportProduct) {
|
||||
function formatBrandLabel(item: PublicTransportProduct | PublicTransportStopProduct) {
|
||||
return resolvePlanBrandDisplayLabel(item) || '—'
|
||||
}
|
||||
|
||||
function resolveFileUrl(url: string) {
|
||||
if (!url) return ''
|
||||
if (/^https?:\/\//i.test(url)) return url
|
||||
const base = (import.meta.env.VITE_MINIO_BASE_URL || '').replace(/\/$/, '')
|
||||
return base ? `${base}/${url.replace(/^\//, '')}` : url
|
||||
function mapStopProductRows(prod: PublicTransportStopProduct): EditableStopProduct {
|
||||
const brandQtyRows = mapBrandQtyRows(prod)
|
||||
return {
|
||||
...prod,
|
||||
brandOptions: prod.brandOptions || [],
|
||||
brandQtyRows,
|
||||
actualQtyText: prod.brandMode
|
||||
? String(Number(brandQtySum(brandQtyRows).toFixed(3)))
|
||||
: prod.actualQty != null
|
||||
? String(prod.actualQty)
|
||||
: ''
|
||||
}
|
||||
}
|
||||
|
||||
function syncUploaderFromImages() {
|
||||
uploaderFiles.value = feedbackImages.value.map((url, index) => ({
|
||||
url: resolveFileUrl(url),
|
||||
isImage: /\.(png|jpe?g|gif|webp|bmp)$/i.test(url),
|
||||
name: `附件${index + 1}`,
|
||||
fileUrl: url
|
||||
})) as UploaderFileListItem[]
|
||||
}
|
||||
|
||||
function mapBrandQtyRows(prod: PublicTransportProduct): BrandQtyItem[] {
|
||||
function mapBrandQtyRows(
|
||||
prod: PublicTransportProduct | PublicTransportStopProduct
|
||||
): BrandQtyItem[] {
|
||||
const existing = (prod.brandQtys || [])
|
||||
.filter((row) => Number(row.qty ?? 0) > 0)
|
||||
.map((row) => ({
|
||||
@@ -366,7 +508,6 @@
|
||||
}))
|
||||
if (existing.length) return existing
|
||||
|
||||
// 指定品牌:仅预选计划上的 brandId,禁止把总量塞到 options 第一项
|
||||
if (prod.brandMode === 'required' && prod.brandId) {
|
||||
const brandName =
|
||||
prod.brandName ||
|
||||
@@ -379,12 +520,79 @@
|
||||
return []
|
||||
}
|
||||
|
||||
function brandModeForField(item: EditableTransportProduct): 'any' | 'required' | null {
|
||||
function resolveFileUrl(url: string) {
|
||||
if (!url) return ''
|
||||
if (/^https?:\/\//i.test(url)) return url
|
||||
const base = (import.meta.env.VITE_MINIO_BASE_URL || '').replace(/\/$/, '')
|
||||
return base ? `${base}/${url.replace(/^\//, '')}` : url
|
||||
}
|
||||
|
||||
function syncStopUploader(stop: StopState) {
|
||||
stop.uploaderFiles = stop.attachmentUrls.map((url, index) => ({
|
||||
url: resolveFileUrl(url),
|
||||
isImage: /\.(png|jpe?g|gif|webp|bmp)$/i.test(url),
|
||||
name: `附件${index + 1}`,
|
||||
fileUrl: url
|
||||
})) as UploaderFileListItem[]
|
||||
}
|
||||
|
||||
function buildStopNavUrl(stop: StopState) {
|
||||
return buildAmapNavigationUrlWithFallback({
|
||||
lng: stop.lng ?? null,
|
||||
lat: stop.lat ?? null,
|
||||
address: stop.address || undefined,
|
||||
name: stop.label
|
||||
})
|
||||
}
|
||||
|
||||
async function handleStopAfterRead(
|
||||
stop: StopState,
|
||||
item: UploaderFileListItem | UploaderFileListItem[]
|
||||
) {
|
||||
const files = Array.isArray(item) ? item : [item]
|
||||
for (const fileItem of files) {
|
||||
if (!fileItem.file) continue
|
||||
fileItem.status = 'uploading'
|
||||
fileItem.message = '上传中...'
|
||||
try {
|
||||
const res = await publicTransportApi.uploadAttachment(token.value, fileItem.file as File)
|
||||
if (res.fileUrl) {
|
||||
stop.attachmentUrls.push(res.fileUrl)
|
||||
;(fileItem as UploaderFileListItem & { fileUrl?: string }).fileUrl = res.fileUrl
|
||||
fileItem.url = resolveFileUrl(res.fileUrl)
|
||||
fileItem.status = 'done'
|
||||
fileItem.message = ''
|
||||
}
|
||||
} catch (e: any) {
|
||||
fileItem.status = 'failed'
|
||||
fileItem.message = e?.message || '上传失败'
|
||||
showFailToast(fileItem.message)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function handleStopBeforeDelete(stop: StopState, index: number) {
|
||||
stop.attachmentUrls.splice(index, 1)
|
||||
return true
|
||||
}
|
||||
|
||||
function syncUploaderFromImages() {
|
||||
uploaderFiles.value = feedbackImages.value.map((url, index) => ({
|
||||
url: resolveFileUrl(url),
|
||||
isImage: /\.(png|jpe?g|gif|webp|bmp)$/i.test(url),
|
||||
name: `附件${index + 1}`,
|
||||
fileUrl: url
|
||||
})) as UploaderFileListItem[]
|
||||
}
|
||||
|
||||
function brandModeForField(
|
||||
item: EditableTransportProduct | EditableStopProduct
|
||||
): 'any' | 'required' | null {
|
||||
if (item.brandMode === 'any' || item.brandMode === 'required') return item.brandMode
|
||||
return null
|
||||
}
|
||||
|
||||
function syncItemActualQty(item: EditableTransportProduct, val: number) {
|
||||
function syncItemActualQty(item: EditableTransportProduct | EditableStopProduct, val: number) {
|
||||
item.actualQtyText = String(val)
|
||||
}
|
||||
|
||||
@@ -392,8 +600,10 @@
|
||||
return rows.reduce((sum, row) => sum + Number(row.qty || 0), 0)
|
||||
}
|
||||
|
||||
function validateBrandedProducts(): string | null {
|
||||
for (const item of editableProducts.value) {
|
||||
function validateBrandedProductRows(
|
||||
items: Array<EditableTransportProduct | EditableStopProduct>
|
||||
): string | null {
|
||||
for (const item of items) {
|
||||
if (!item.brandMode) continue
|
||||
const positiveRows = (item.brandQtyRows || []).filter((r) => Number(r.qty) > 0)
|
||||
if (!positiveRows.length) {
|
||||
@@ -408,6 +618,33 @@
|
||||
return null
|
||||
}
|
||||
|
||||
function validateBrandedProducts(): string | null {
|
||||
if (useMultiStop.value) {
|
||||
for (const stop of stopStates.value) {
|
||||
const err = validateBrandedProductRows(stop.editableProducts)
|
||||
if (err) return err
|
||||
}
|
||||
return null
|
||||
}
|
||||
return validateBrandedProductRows(editableProducts.value)
|
||||
}
|
||||
|
||||
function buildStopProductsPayload(stop: StopState) {
|
||||
return stop.editableProducts.map((item) => ({
|
||||
stopProductId: item.stopProductId,
|
||||
actualQty: Number(item.actualQtyText || 0),
|
||||
brandQtys: item.brandMode
|
||||
? (item.brandQtyRows || [])
|
||||
.filter((row) => Number(row.qty) > 0)
|
||||
.map((row) => ({
|
||||
brandId: row.brandId,
|
||||
brandName: row.brandName,
|
||||
qty: Number(row.qty)
|
||||
}))
|
||||
: undefined
|
||||
}))
|
||||
}
|
||||
|
||||
async function loadPage() {
|
||||
loading.value = true
|
||||
errorMessage.value = ''
|
||||
@@ -416,6 +653,16 @@
|
||||
page.value = data
|
||||
feedbackRemark.value = data.feedbackRemark || ''
|
||||
feedbackImages.value = [...(data.feedbackImages || [])]
|
||||
stopStates.value = (data.stops || []).map((stop) => {
|
||||
const state: StopState = {
|
||||
...stop,
|
||||
attachmentUrls: [...(stop.attachmentUrls || [])],
|
||||
uploaderFiles: [],
|
||||
editableProducts: (stop.products || []).map(mapStopProductRows)
|
||||
}
|
||||
syncStopUploader(state)
|
||||
return state
|
||||
})
|
||||
editableProducts.value = (data.products || []).map((prod) => {
|
||||
const brandQtyRows = mapBrandQtyRows(prod)
|
||||
return {
|
||||
@@ -467,36 +714,57 @@
|
||||
}
|
||||
|
||||
async function handleSave() {
|
||||
const brandErr = validateBrandedProducts()
|
||||
if (brandErr) {
|
||||
showFailToast(brandErr)
|
||||
return
|
||||
if (DRIVER_QTY_FEEDBACK_VISIBLE) {
|
||||
const brandErr = validateBrandedProducts()
|
||||
if (brandErr) {
|
||||
showFailToast(brandErr)
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
const products = editableProducts.value.map((item) => {
|
||||
const actualQty = Number(item.actualQtyText || 0)
|
||||
return {
|
||||
planProductId: item.planProductId,
|
||||
actualQty,
|
||||
brandQtys: item.brandMode
|
||||
? (item.brandQtyRows || [])
|
||||
.filter((row) => Number(row.qty) > 0)
|
||||
.map((row) => ({
|
||||
brandId: row.brandId,
|
||||
brandName: row.brandName,
|
||||
qty: Number(row.qty)
|
||||
}))
|
||||
: undefined
|
||||
}
|
||||
})
|
||||
const products = DRIVER_QTY_FEEDBACK_VISIBLE
|
||||
? editableProducts.value.map((item) => {
|
||||
const actualQty = Number(item.actualQtyText || 0)
|
||||
return {
|
||||
planProductId: item.planProductId,
|
||||
actualQty,
|
||||
brandQtys: item.brandMode
|
||||
? (item.brandQtyRows || [])
|
||||
.filter((row) => Number(row.qty) > 0)
|
||||
.map((row) => ({
|
||||
brandId: row.brandId,
|
||||
brandName: row.brandName,
|
||||
qty: Number(row.qty)
|
||||
}))
|
||||
: undefined
|
||||
}
|
||||
})
|
||||
: undefined
|
||||
|
||||
saving.value = true
|
||||
try {
|
||||
await publicTransportApi.saveFeedback(token.value, {
|
||||
feedbackRemark: feedbackRemark.value,
|
||||
feedbackImages: feedbackImages.value,
|
||||
products
|
||||
})
|
||||
if (useMultiStop.value) {
|
||||
for (const stop of stopStates.value) {
|
||||
await publicTransportApi.saveDriverStopFeedback(token.value, {
|
||||
stopType: stop.stopType,
|
||||
stopId: stop.stopId,
|
||||
attachmentUrls: stop.attachmentUrls,
|
||||
...(DRIVER_QTY_FEEDBACK_VISIBLE
|
||||
? { products: buildStopProductsPayload(stop) }
|
||||
: {})
|
||||
})
|
||||
}
|
||||
await publicTransportApi.saveFeedback(token.value, {
|
||||
feedbackRemark: feedbackRemark.value,
|
||||
feedbackImages: []
|
||||
})
|
||||
} else {
|
||||
await publicTransportApi.saveFeedback(token.value, {
|
||||
feedbackRemark: feedbackRemark.value,
|
||||
feedbackImages: feedbackImages.value,
|
||||
...(products ? { products } : {})
|
||||
})
|
||||
}
|
||||
showSuccessToast('保存成功')
|
||||
await loadPage()
|
||||
} catch (e: any) {
|
||||
@@ -664,9 +932,6 @@
|
||||
|
||||
.meta-row--span {
|
||||
grid-column: 1 / -1;
|
||||
flex-direction: row;
|
||||
align-items: baseline;
|
||||
gap: 4px;
|
||||
}
|
||||
|
||||
.meta-row__label {
|
||||
@@ -773,4 +1038,26 @@
|
||||
.history-btn {
|
||||
color: #fff !important;
|
||||
}
|
||||
|
||||
.stop-uploader-wrap {
|
||||
padding: 8px 16px 12px;
|
||||
}
|
||||
|
||||
.stop-products-wrap {
|
||||
padding: 0 0 4px;
|
||||
}
|
||||
|
||||
.stop-products-title {
|
||||
margin: 0 16px 6px;
|
||||
font-size: 13px;
|
||||
font-weight: 600;
|
||||
color: #64748b;
|
||||
}
|
||||
|
||||
.stop-uploader-label {
|
||||
margin-bottom: 8px;
|
||||
font-size: 13px;
|
||||
font-weight: 500;
|
||||
color: #64748b;
|
||||
}
|
||||
</style>
|
||||
Reference in new issue
Block a user