This commit is contained in:
yin 2026-07-01 18:16:50 +08:00
parent 1d3e0c0f64
commit 7558b61e33
5 changed files with 79 additions and 15 deletions

Binary file not shown.

View File

@ -514,23 +514,29 @@ export function getDirectInboundItems(
export type DirectInboundAddItemBatchEntry = {
stock_id: number
quantity: number
quantity?: number
inbound_type: 'import' | 'pda' | string
space_id?: number
remark?: string
receiving_detail_id?: number
allocated_quantity?: number
}
export type DirectInboundAddItemSingleParams = {
entry_order_code: string
/** 入库单 ID */
entry_order_id: number
stock_id: number
quantity: number
quantity?: number
inbound_type: 'import' | 'pda' | string
space_id?: number
remark?: string
receiving_detail_id?: number
allocated_quantity?: number
}
export type DirectInboundAddItemBatchParams = {
entry_order_code: string
/** 入库单 ID */
entry_order_id: number
items: DirectInboundAddItemBatchEntry[]
}

View File

@ -1303,7 +1303,52 @@ function mapPendingOrderItemsToPrintDetails(items: Record<string, unknown>[]) {
})
}
/** 将 order.pendingOrder.detail 响应映射为出库单打印表单字段 */
/** 打印脱敏:收件人仅保留首字(姓),其余替换为 * */
export function maskPrintReceiverName(name: unknown): string {
const text = String(name ?? '').trim()
if (!text) return ''
if (text.length === 1) return text
return text.charAt(0) + '*'.repeat(text.length - 1)
}
/** 打印脱敏:电话保留前三位和最后四位,中间替换为 * */
export function maskPrintReceiverPhone(phone: unknown): string {
const text = String(phone ?? '').trim()
if (!text) return ''
if (text.length <= 7) {
if (text.length <= 3) return text
return text.slice(0, 3) + '*'.repeat(text.length - 3)
}
const prefix = text.slice(0, 3)
const suffix = text.slice(-4)
return prefix + '*'.repeat(text.length - 7) + suffix
}
/** 打印脱敏:详细地址中的阿拉伯数字替换为 * */
export function maskPrintDetailAddressDigits(address: unknown): string {
const text = String(address ?? '').trim()
if (!text) return ''
return text.replace(/[0-9]/g, '*')
}
function applySandanOutboundPrintReceiverMask(form: Record<string, unknown>): Record<string, unknown> {
const mobile = maskPrintReceiverPhone(form.mobile ?? form.tel)
const tel = maskPrintReceiverPhone(form.tel ?? form.mobile)
const detailAddress = maskPrintDetailAddressDigits(form.detail_address)
const addressParts = [form.province, form.city, form.area, form.town, detailAddress]
.map((value) => (value == null ? '' : String(value).trim()))
.filter(Boolean)
return {
...form,
name: maskPrintReceiverName(form.name),
mobile,
tel: tel || mobile,
detail_address: detailAddress,
address: addressParts.join(''),
}
}
/** 将 order.pendingOrder.detail 响应映射为出库单打印表单字段(散单波次打印货单会对收件人/电话脱敏) */
export function mapPendingOrderToOutboundPrintForm(
detailPayload: Record<string, unknown>,
wave: Record<string, unknown>,
@ -1315,7 +1360,7 @@ export function mapPendingOrderToOutboundPrintForm(
.map((value) => (value == null ? '' : String(value).trim()))
.filter(Boolean)
return {
return applySandanOutboundPrintReceiverMask({
...order,
wave_no: String(wave.wave_no ?? wave.batch_no ?? wave.wave_code ?? order.wave_no ?? '—'),
delivery_order_code: resolvePendingOrderDeliveryCode(order),
@ -1337,7 +1382,7 @@ export function mapPendingOrderToOutboundPrintForm(
remark: order.remark ?? order.seller_message ?? order.buyer_message ?? '',
print_time: formatOutboundPrintDateTime(new Date()),
details: mapPendingOrderItemsToPrintDetails(items),
}
})
}
/**
@ -1428,7 +1473,9 @@ export async function fetchOutboundPrintDataFromPendingOrders(
if (!orderId) {
if (deliveryCode) missingDeliveryCodes.push(deliveryCode)
dataMap[rowKey] = skeleton.dataMap[rowKey] || toOutboundPrintForm({}, wave)
dataMap[rowKey] = applySandanOutboundPrintReceiverMask(
(skeleton.dataMap[rowKey] || toOutboundPrintForm({}, wave)) as Record<string, unknown>,
)
printRows[index] = row
return
}
@ -1444,7 +1491,9 @@ export async function fetchOutboundPrintDataFromPendingOrders(
}
if (deliveryCode) missingDeliveryCodes.push(deliveryCode)
dataMap[rowKey] = skeleton.dataMap[rowKey] || toOutboundPrintForm({}, wave)
dataMap[rowKey] = applySandanOutboundPrintReceiverMask(
(skeleton.dataMap[rowKey] || toOutboundPrintForm({}, wave)) as Record<string, unknown>,
)
printRows[index] = row
},
)

View File

@ -230,7 +230,7 @@ import { ElMessage, type FormInstance, type FormRules, type UploadFile } from 'e
import { Search } from '@element-plus/icons-vue'
import UpperTable from '@/components/UpperTable/index.vue'
import * as indexApi from '@/api/index/index'
import { addDirectInboundItem } from '@/api/storage.directinbound/directinbound'
import { addDirectInboundItem } from '@/api/storage.entry/entry'
import { directInboundInboundTypeOptions } from '../entry-config'
import {
downloadDirectInboundImportTemplate,
@ -247,6 +247,8 @@ export type { DirectInboundImportRow }
const props = defineProps<{
modelValue: boolean
/** 入库单 ID(storage.entry.addDirectInboundItem 必填) */
entryOrderId?: string | number
entryOrderCode?: string
/** 单条导入目标 */
targetItem?: DirectInboundImportRow | null
@ -540,9 +542,9 @@ function handleClosed() {
}
async function handleSubmit() {
const code = props.entryOrderCode
if (!code) {
ElMessage.warning('缺少入库单号')
const entryOrderId = Number(props.entryOrderId)
if (!Number.isFinite(entryOrderId) || entryOrderId <= 0) {
ElMessage.warning('缺少入库单 ID')
return
}
@ -560,7 +562,7 @@ async function handleSubmit() {
}
const res = await addDirectInboundItem({
entry_order_code: code,
entry_order_id: entryOrderId,
stock_id: Number(singleTarget.value.stock_id),
quantity: Number(singleForm.quantity),
inbound_type: singleForm.inbound_type,
@ -592,7 +594,7 @@ async function handleSubmit() {
}
const res = await addDirectInboundItem({
entry_order_code: code,
entry_order_id: entryOrderId,
items: parsedRows.value.map((row) => ({
stock_id: Number(row.stock_id),
quantity: Number(row.quantity),

View File

@ -68,6 +68,7 @@
<DirectInboundImportDialog
v-model="importDialogVisible"
:entry-order-id="entryOrderId"
:entry-order-code="entryOrderCode"
:target-item="importTargetItem"
:batch-file-mode="batchFileMode"
@ -109,6 +110,12 @@ const loading = ref(false)
const commitLoading = ref(false)
const multipleSelection = ref<Record<string, unknown>[]>([])
const entryOrderStatus = ref('')
const entryOrderId = computed(() => {
const fromProps = Number(props.id)
if (Number.isFinite(fromProps) && fromProps > 0) return fromProps
const fromRow = Number(props.row?.id)
return Number.isFinite(fromRow) && fromRow > 0 ? fromRow : undefined
})
const entryOrderCode = ref('')
const directSummary = ref<Record<string, unknown>>({})