This commit is contained in:
zlwu committed 2026-08-23 18:42:27 +08:00
1 parent b74d483682
commit dd1acdc787
50 files changed
+636156 -7218

No files matched your search

+4 -28
View File
@@ -1,7 +1,6 @@
// web-admin/src/utils/pl-batch-print.ts
import type { Plan, PlanProduct } from '@/api/pl'
import type { PlPrintSlipCommand } from '@/utils/pl-display'
import { canPrintSlipCommand } from '@/utils/pl-display'
export type SlipPlanProduct = PlanProduct & { slipPlanNo?: string }
@@ -10,52 +9,29 @@ export function normalizeCustomerName(name?: string | null) {
}
export function canBatchPrintSlip(
plans: Array<Pick<Plan, 'planType' | 'customerName' | 'planDate'>>,
plans: Array<Pick<Plan, 'customerName' | 'planDate'>>,
command: PlPrintSlipCommand
): { ok: boolean; reason?: string } {
if (!plans?.length) return { ok: false, reason: '请先勾选运输计划' }
if (plans.length === 1) {
if (!canPrintSlipCommand(plans[0].planType, command)) {
return { ok: false, reason: '当前单据类型不支持打印该单据' }
}
return { ok: true }
}
if (command === 'inbound') {
if (!plans.every((p) => p.planType === 'inbound')) {
return { ok: false, reason: '合打入库单要求:均为入库类计划' }
}
if (command === 'inbound' || command === 'delivery') {
const c = normalizeCustomerName(plans[0].customerName)
const d = plans[0].planDate
const slipLabel = command === 'inbound' ? '入库单' : '送(提)货单'
if (!c || !d || !plans.every((p) => normalizeCustomerName(p.customerName) === c && p.planDate === d)) {
return {
ok: false,
reason: '合打入库单要求:客户名称一致且计划日期一致,且均为入库类计划'
}
}
return { ok: true }
}
if (command === 'delivery') {
if (!plans.every((p) => p.planType === 'outbound')) {
return { ok: false, reason: '合打送(提)货单要求:均为出库类计划' }
}
const c = normalizeCustomerName(plans[0].customerName)
const d = plans[0].planDate
if (!c || !d || !plans.every((p) => normalizeCustomerName(p.customerName) === c && p.planDate === d)) {
return {
ok: false,
reason: '合打送(提)货单要求:客户名称一致且计划日期一致,且均为出库类计划'
reason: `合打${slipLabel}要求:客户名称一致且计划日期一致`
}
}
return { ok: true }
}
if (command === 'subpack') {
if (!plans.every((p) => canPrintSlipCommand(p.planType, 'subpack'))) {
return { ok: false, reason: '分装单仅支持出库类计划' }
}
return { ok: true }
}
+28 -12
View File
@@ -130,6 +130,24 @@ export function getPlanProductActualQuantity(product: {
return String(qty)
}
/** 列表「入库数量」列 */
export function getPlanProductInboundQuantity(product: {
inboundQty?: number | string | null
}) {
const qty = product.inboundQty
if (qty === undefined || qty === null || qty === '') return '—'
return String(qty)
}
/** 列表「出库数量」列 */
export function getPlanProductOutboundQuantity(product: {
outboundQty?: number | string | null
}) {
const qty = product.outboundQty
if (qty === undefined || qty === null || qty === '') return '—'
return String(qty)
}
export function formatPlanProductListText(
product: {
productName?: string
@@ -306,20 +324,18 @@ export function getPlPlanTypeLabel(type?: string) {
/** 打印单据下拉项:入库单 / 送(提)货单 / 分装单 */
export type PlPrintSlipCommand = 'inbound' | 'delivery' | 'subpack'
/**
* 按运输计划单据类型返回可打印的单据命令。
* - inbound:仅入库单
* - outbound:送(提)货单、分装单
* - direct / 其他:不可打印
*/
export function getPrintableSlipCommands(planType?: string): PlPrintSlipCommand[] {
if (planType === 'inbound') return ['inbound']
if (planType === 'outbound') return ['delivery', 'subpack']
return []
/** 运输计划可打印的单据命令(不区分单据类型,由用户自行选择) */
export const PL_PRINT_SLIP_COMMANDS: PlPrintSlipCommand[] = ['inbound', 'delivery', 'subpack']
export function getPrintableSlipCommands(_planType?: string): PlPrintSlipCommand[] {
return PL_PRINT_SLIP_COMMANDS
}
export function canPrintSlipCommand(planType: string | undefined, command: PlPrintSlipCommand) {
return getPrintableSlipCommands(planType).includes(command)
export function canPrintSlipCommand(
_planType: string | undefined,
_command: PlPrintSlipCommand
) {
return true
}
export type PlPlanTypeTab = 'all' | 'inbound' | 'outbound' | 'direct'