This commit is contained in:
yin 2026-09-15 18:31:55 +08:00
parent 4ecf3c32b8
commit 3e9095c73e
56 changed files with 2755 additions and 745 deletions

View File

@ -18,6 +18,13 @@ export type OrderPagination = {
export type ArchiveOrderListParams = {
pagination?: OrderPagination
/**
* 统一 where 条件对象;禁止传入 warehouse_id / warehouseId(后端按登录仓库上下文注入)。
* create_channel 订单来源渠道筛选(按订单表 create_channel 列过滤;枚举:MANUAL=手工单、API=接口、QM=奇门、STOCKOUT=出库转单):
* {"create_channel":"MANUAL"} 单值精确;{"create_channel":["QM","API"]} 裸数组按 in 多选;
* {"create_channel":{"operator":"in","value":["QM","API"]}} 标准结构多选;{"create_channel":{"operator":"ne","value":"MANUAL"}} 排除指定渠道。
* 注意:列表响应中的 create_channel 已格式化为中文标签,查询条件须传英文枚举值。
*/
where?: OrderWhere
sort?: OrderSort
}

View File

@ -18,6 +18,13 @@ export type OrderPagination = {
export type DeliveryExpectionOrderListParams = {
pagination?: OrderPagination
/**
* 统一 where 条件对象;禁止传入 warehouse_id / warehouseId(后端按登录仓库上下文注入)。
* create_channel 订单来源渠道筛选(按订单表 create_channel 列过滤;枚举:MANUAL=手工单、API=接口、QM=奇门、STOCKOUT=出库转单):
* {"create_channel":"MANUAL"} 单值精确;{"create_channel":["QM","API"]} 裸数组按 in 多选;
* {"create_channel":{"operator":"in","value":["QM","API"]}} 标准结构多选;{"create_channel":{"operator":"ne","value":"MANUAL"}} 排除指定渠道。
* 注意:列表响应中的 create_channel 已格式化为中文标签,查询条件须传英文枚举值。
*/
where?: OrderWhere
sort?: OrderSort
}

View File

@ -18,6 +18,13 @@ export type OrderPagination = {
export type DeliveryOrderListParams = {
pagination?: OrderPagination
/**
* 统一 where 条件对象;禁止传入 warehouse_id / warehouseId(后端按登录仓库上下文注入)。
* create_channel 订单来源渠道筛选(按订单表 create_channel 列过滤;枚举:MANUAL=手工单、API=接口、QM=奇门、STOCKOUT=出库转单):
* {"create_channel":"MANUAL"} 单值精确;{"create_channel":["QM","API"]} 裸数组按 in 多选;
* {"create_channel":{"operator":"in","value":["QM","API"]}} 标准结构多选;{"create_channel":{"operator":"ne","value":"MANUAL"}} 排除指定渠道。
* 注意:列表响应中的 create_channel 已格式化为中文标签,查询条件须传英文枚举值。
*/
where?: OrderWhere
sort?: OrderSort
}
@ -237,6 +244,10 @@ export function orderDeliveryOrderDetail(data: DeliveryOrderDetailParams): Promi
} as any)
}
/**
* order.deliveryOrder.quickSearch:按关键词跨表联合搜索(运单号/发货单号/外部订单号/平台交易单号)
* 工单页「发起售后单-关联订单-选择订单」使用;联合查询较慢,超时时间延长至 20 秒(axios 默认 10 秒)
*/
export function orderDeliveryOrderQuickSearch(keyword: string): Promise<any> {
return request({
url: '/system',
@ -247,7 +258,9 @@ export function orderDeliveryOrderQuickSearch(keyword: string): Promise<any> {
timestamp: Date.now()
},
data: { keyword },
isSystemApi: true
isSystemApi: true,
// 联合搜索耗时较长,单独放宽超时时间至 20 秒
timeout: 60000
} as any)
}

View File

@ -18,6 +18,13 @@ export type OrderPagination = {
export type EntrustOrderListParams = {
pagination?: OrderPagination
/**
* 统一 where 条件对象;禁止传入 warehouse_id / warehouseId(后端按登录仓库上下文注入)。
* create_channel 订单来源渠道筛选(按订单表 create_channel 列过滤;枚举:MANUAL=手工单、API=接口、QM=奇门、STOCKOUT=出库转单):
* {"create_channel":"MANUAL"} 单值精确;{"create_channel":["QM","API"]} 裸数组按 in 多选;
* {"create_channel":{"operator":"in","value":["QM","API"]}} 标准结构多选;{"create_channel":{"operator":"ne","value":"MANUAL"}} 排除指定渠道。
* 注意:列表响应中的 create_channel 已格式化为中文标签,查询条件须传英文枚举值。
*/
where?: OrderWhere
sort?: OrderSort
}

View File

@ -18,6 +18,13 @@ export type OrderPagination = {
export type ExpectionOrderListParams = {
pagination?: OrderPagination
/**
* 统一 where 条件对象;禁止传入 warehouse_id / warehouseId(后端按登录仓库上下文注入)。
* create_channel 订单来源渠道筛选(按订单表 create_channel 列过滤;枚举:MANUAL=手工单、API=接口、QM=奇门、STOCKOUT=出库转单):
* {"create_channel":"MANUAL"} 单值精确;{"create_channel":["QM","API"]} 裸数组按 in 多选;
* {"create_channel":{"operator":"in","value":["QM","API"]}} 标准结构多选;{"create_channel":{"operator":"ne","value":"MANUAL"}} 排除指定渠道。
* 注意:列表响应中的 create_channel 已格式化为中文标签,查询条件须传英文枚举值。
*/
where?: OrderWhere
sort?: OrderSort
}

View File

@ -16,7 +16,13 @@ export type OrderListParams = {
* - 虚拟字段:buyer_message_has(覆盖 buyer_message/seller_message/remark 三个字段,任一有值即为有留言,value=true/false)、
* express_numbers / waybill_codes(运单号筛选)、
* wave_index(波次内序号筛选,联查 wms_order_wave_index,支持 eq/in/gt/lt/ge/le/between/notbetween,
* between 要求 value 为长度 2 的数组,如 {"wave_index":{"operator":"between","value":[1,50]}})。
* between 要求 value 为长度 2 的数组,如 {"wave_index":{"operator":"between","value":[1,50]}})、
* wave_scope(波次范围筛选,直接按订单表 wave_scope 列过滤;取值 0=未分配、1=大团购、2=散单、3=小团购、4=单品单件。
* 支持 {"wave_scope":0} 单值、{"wave_scope":[1,3]} 裸数组、{"wave_scope":{"operator":"in","value":[1,3]}} 标准结构)。
* - create_channel 订单来源渠道筛选(按订单表 create_channel 列过滤;枚举:MANUAL=手工单、API=接口、QM=奇门、STOCKOUT=出库转单):
* {"create_channel":"MANUAL"} 单值精确;{"create_channel":["QM","API"]} 裸数组按 in 多选;
* {"create_channel":{"operator":"in","value":["QM","API"]}} 标准结构多选;{"create_channel":{"operator":"ne","value":"MANUAL"}} 排除指定渠道。
* 注意:列表响应中的 create_channel 已格式化为中文标签,查询条件须传英文枚举值。
*/
where?: Record<string, any>
sort?: {

View File

@ -18,6 +18,13 @@ export type OrderPagination = {
export type OutboundOrderListParams = {
pagination?: OrderPagination
/**
* 统一 where 条件对象;禁止传入 warehouse_id / warehouseId(后端按登录仓库上下文注入)。
* create_channel 订单来源渠道筛选(按订单表 create_channel 列过滤;枚举:MANUAL=手工单、API=接口、QM=奇门、STOCKOUT=出库转单):
* {"create_channel":"MANUAL"} 单值精确;{"create_channel":["QM","API"]} 裸数组按 in 多选;
* {"create_channel":{"operator":"in","value":["QM","API"]}} 标准结构多选;{"create_channel":{"operator":"ne","value":"MANUAL"}} 排除指定渠道。
* 注意:列表响应中的 create_channel 已格式化为中文标签,查询条件须传英文枚举值。
*/
where?: OrderWhere
sort?: OrderSort
}

View File

@ -43,6 +43,10 @@ export type PendingOrderListParams = {
* 统一 where 条件对象;禁止传入 warehouse_id / warehouseId。where 无字段白名单,可直接传订单表列名。
* lock_status 锁定状态筛选(筛选值用数据库原始枚举 none/warehouse/store,不是响应中的 Y/N;ne 表示不等于;条件值为空自动忽略):
* 未锁定 {"lock_status":"none"};已锁定(所有非 none){"lock_status":{"operator":"ne","value":"none"}}
* create_channel 订单来源渠道筛选(按订单表 create_channel 列过滤;枚举:MANUAL=手工单、API=接口、QM=奇门、STOCKOUT=出库转单):
* {"create_channel":"MANUAL"} 单值精确;{"create_channel":["QM","API"]} 裸数组按 in 多选;
* {"create_channel":{"operator":"in","value":["QM","API"]}} 标准结构多选;{"create_channel":{"operator":"ne","value":"MANUAL"}} 排除指定渠道。
* 注意:列表响应中的 create_channel 已格式化为中文标签,查询条件须传英文枚举值。
*/
where?: OrderWhere;
sort?: OrderSort;

View File

@ -18,6 +18,13 @@ export type OrderPagination = {
export type ReviewOrderListParams = {
pagination?: OrderPagination
/**
* 统一 where 条件对象;禁止传入 warehouse_id / warehouseId(后端按登录仓库上下文注入)。
* create_channel 订单来源渠道筛选(按订单表 create_channel 列过滤;枚举:MANUAL=手工单、API=接口、QM=奇门、STOCKOUT=出库转单):
* {"create_channel":"MANUAL"} 单值精确;{"create_channel":["QM","API"]} 裸数组按 in 多选;
* {"create_channel":{"operator":"in","value":["QM","API"]}} 标准结构多选;{"create_channel":{"operator":"ne","value":"MANUAL"}} 排除指定渠道。
* 注意:列表响应中的 create_channel 已格式化为中文标签,查询条件须传英文枚举值。
*/
where?: OrderWhere
sort?: OrderSort
}

View File

@ -730,6 +730,83 @@ export function returnUnpackExportTaskProgress(data: ReturnUnpackExportTaskProgr
} as any)
}
// ============ returnUnpack.transferByWaybills ============
/** returnUnpack.transferByWaybills 请求参数 */
export type ReturnUnpackTransferByWaybillsParams = {
/** 运单表主键ID列表(wms_order_express.id,也兼容单个数值;服务端 Number() 归一化 + 过滤非正整数 + 去重,去重后单次上限 200) */
ids: number[] | number
}
/** returnUnpack.transferByWaybills 成功项 */
export type ReturnUnpackTransferSuccessItem = {
/** 运单表主键ID(wms_order_express.id) */
waybill_id: number
/** 运单号 */
waybill_code: string
/** 拆包单ID */
unpack_id: number
/** 拆包单号 */
unpack_no: string
/** true=命中已有有效拆包单,直接复用未重复创建 */
reused: boolean
/** 明细行数 */
detail_count: number
/** 明细数量合计 */
total_quantity: number
}
/** returnUnpack.transferByWaybills 失败项 */
export type ReturnUnpackTransferFailedItem = {
/** 运单表主键ID(wms_order_express.id) */
waybill_id?: number | null
/** 运单号(运单命中时才有值,否则为 null) */
waybill_code?: string | null
/** 失败原因,如「运单不存在」「运单为子单(business_key>1),跳过」「运单号为空,无法转入退件登记」「运单关联订单无明细可复制」 */
reason: string
}
/** returnUnpack.transferByWaybills 响应(逐单处理,单条失败不阻断主流程,HTTP 整体仍成功) */
export type ReturnUnpackTransferByWaybillsResponse = {
code?: number
message?: string
/** 去重后待处理运单总数 */
total: number
/** 成功转入数量 */
success_count: number
/** 失败数量 */
failed_count: number
/** 成功项数组 */
success: ReturnUnpackTransferSuccessItem[]
/** 失败项数组 */
failed: ReturnUnpackTransferFailedItem[]
}
/**
* returnUnpack.transferByWaybills:运单批量转入退件登记(一次调用把多个运单批量转入退回拆包登记)
* - `ids` 为运单表主键ID(wms_order_express.id),支持单个数值或数组;服务端 Number() 归一化 + 过滤非正整数 + 去重,去重后单次上限 200
* - 仓库隔离:warehouse_id 由服务端从 ctx.user.store_id 注入,禁止前端传入;服务端按 id IN (ids) + 仓库一次批量反查 wms_order_express,未命中(不存在/非本仓库)记失败「运单不存在」
* - 逐单处理,单条失败不阻断主流程:失败项进入 failed[](HTTP 整体仍成功)
* - 子单(business_key>1)跳过(一个运单只允许一条有效拆包单);运单号为空时记失败「运单号为空,无法转入退件登记」;命中运单统一置 wms_order_express.is_back='Y'
* - 幂等:同仓库 + 同运单号已存在 status != 'cancelled' 的拆包单时直接复用(reused=true));复用单明细为空时按订单明细补写,已有明细不重复写入
* - 明细来源:运单关联订单的原本明细 1:1 复制(订单 items 优先,为空回退明细分表);命中退回收到登记时回填主表 return_received_id(失败仅告警不阻断)
*/
export function returnUnpackTransferByWaybills(
data: ReturnUnpackTransferByWaybillsParams
): Promise<ReturnUnpackTransferByWaybillsResponse> {
return request({
url: '/system',
method: 'post',
params: {
method: 'returnUnpack.transferByWaybills',
v,
timestamp: new Date().getTime()
},
data,
isSystemApi: true
} as any)
}
// ============ 模块导出 ============
export const returnUnpackModule = {
@ -745,5 +822,6 @@ export const returnUnpackModule = {
delete: returnUnpackDelete,
forceRecord: returnUnpackForceRecord,
export: returnUnpackExport,
exportTaskProgress: returnUnpackExportTaskProgress
exportTaskProgress: returnUnpackExportTaskProgress,
transferByWaybills: returnUnpackTransferByWaybills
}

View File

@ -127,6 +127,72 @@ export function getInventoryListBySpaceId(data: InventoryListBySpaceIdParams): P
} as any)
}
/** storage.inventory.updateExpiry 请求参数 */
export type InventoryUpdateExpiryParams = {
/** 库存记录ID(wms_storage.id,必填,正整数) */
storage_id: number
/** 生产日期,支持 YYYY-MM-DD / YYYY/MM/DD / YYYY-MM-DD HH:mm:ss / ISO 字符串;传 null 或空串表示清空。与 expiry_date 至少传一个,未传则保持库内原值 */
production_date?: string | null
/** 到期日期,格式要求同 production_date;传 null 或空串表示清空。与 production_date 至少传一个,未传则保持库内原值 */
expiry_date?: string | null
}
/** storage.inventory.updateExpiry 响应 data(维护结果) */
export type InventoryUpdateExpiryResult = {
/** 库存记录ID(wms_storage.id) */
storage_id?: number
/** 仓库ID(取自当前登录用户 ctx.user.store_id) */
warehouse_id?: number
/** 货主ID */
store_id?: number
/** 库位ID */
space_id?: number
/** 商品SKU ID(wms_stock_warehouse.id) */
stock_id?: number
/** 批次号 */
batch_no?: string
/** 维护后的生产日期(YYYY-MM-DD),未维护时为 null */
production_date?: string | null
/** 维护后的到期日期(YYYY-MM-DD),未维护时为 null */
expiry_date?: string | null
/** 维护前的生产日期(YYYY-MM-DD),原为空时为 null */
before_production_date?: string | null
/** 维护前的到期日期(YYYY-MM-DD),原为空时为 null */
before_expiry_date?: string | null
/** 是否发生了实际变更(false 表示传入值与库内现值一致,未写库) */
changed?: boolean
[key: string]: unknown
}
/** storage.inventory.updateExpiry 响应(request 拦截器返回完整响应体) */
export type InventoryUpdateExpiryResponse = {
code?: number
message?: string
data?: InventoryUpdateExpiryResult | null
}
/**
* 按库存记录维度维护生产日期与到期日期
* - `storage_id` 必填(wms_storage.id);`production_date` / `expiry_date` 至少传一个,未传的字段保持库内原值,传 null 或空串表示清空
* - 日期支持 YYYY-MM-DD / YYYY/MM/DD / YYYY-MM-DD HH:mm:ss / ISO 字符串,后端统一按 YYYY-MM-DD 落库
* - 合并后的生产日期不得晚于到期日期(未传字段取库内现值参与比较),校验失败返回 400
* - 仅允许维护当前登录仓库(ctx.user.store_id)下的库存记录,跨仓库的 storage_id 按「不存在」处理(404);库存记录被锁定返回 409
* - 更新前后完全一致时返回 changed=false,不写库、不记操作日志
*/
export function updateInventoryExpiry(data: InventoryUpdateExpiryParams): Promise<InventoryUpdateExpiryResponse> {
return request({
url: '/system',
method: 'post',
params: {
method: 'storage.inventory.updateExpiry',
v,
timestamp: new Date().getTime()
},
data,
isSystemApi: true
} as any)
}
export function quickPutaway(data: { receiving_id: number; id?: number }): Promise<any> {
const body: Record<string, unknown> = { ...data }
if (body.receiving_id === undefined && body.id != null) {

View File

@ -188,21 +188,12 @@ export const stockoutConfirm = (data: StockoutConfirmParams) => {
export type StockoutUpdateExpressParams = {
/** 出库单ID(必填) */
id: number
<<<<<<< HEAD
/** 快递公司编码(非运单号,如 SF/STO/ZT);传入后自动解析 express_name,传空值置 NULL */
express_code?: string
/** 运单号(单个);storage.stockout.confirm 前必须已填写该字段 */
waybill_code?: string
/** 运单号列表(JSON 数组或 null,支持多包裹场景);非数组返回 400 */
waybill_codes?: string[] | null
=======
/** 快递公司编码(**非运单号**,如 SF/STO/ZT):传入后后端自动解析 express_name,传空值则 express_code/express_name 置 NULL */
express_code?: string
/** 运单号列表(JSON 数组或 null,支持一单多运单);回传与确认校验以此为准,传空数组或 null 表示清空;非数组返回 400 */
waybill_codes?: string[] | null
/** 【已弃用】单数运单号:仅作 waybill_codes 首个的镜像,勿单独使用 */
waybill_code?: string
>>>>>>> f4db2401638744bb2c1a5d132f23f0f470b76598
}
/** storage.stockout.updateExpress 响应 */
@ -211,19 +202,6 @@ export type StockoutUpdateExpressResponse = {
stockout_order_code: string
/** 更新后的快递公司编码 */
express_code?: string
<<<<<<< HEAD
/** 由 express_code 解析出的快递公司名称 */
express_name?: string
/** 更新后的运单号 */
waybill_code?: string
/** 更新后的运单号列表 */
waybill_codes?: string[]
}
/**
* 更新出库单的快递公司与运单号(express_code / waybill_code / waybill_codes),用于在确认前填写运单信息。
* 未传入的字段不更新,三个字段都未传时返回「没有需要更新的字段」;已废弃字段 express_codes 不在本接口读写范围内。
=======
/** 由 express_code 解析出的快递公司名称(未匹配到为空串) */
express_name?: string
/** 更新后的运单号列表(以此为准) */
@ -236,7 +214,6 @@ export type StockoutUpdateExpressResponse = {
* 更新出库单的快递公司与运单号(确认前填写运单信息)
* - `express_code` 是**快递公司编码**,不是运单号
* - 运单号统一走 `waybill_codes`(复数数组);`waybill_code` 已弃用,`express_codes` 已废弃(不在本接口读写范围内)
>>>>>>> f4db2401638744bb2c1a5d132f23f0f470b76598
*/
export const stockoutUpdateExpress = (data: StockoutUpdateExpressParams) => {
return request({

View File

@ -139,7 +139,7 @@ export const videoEnableConfig: Record<number, { text: string; tagType: 'success
// =============================================================================
export const packingColumns = [
{ prop: 'id', label: '任务ID', width: 90 },
// { prop: 'id', label: '任务ID', width: 90 },
{ prop: 'order_id', label: '订单ID', width: 100 },
{ prop: 'waybill_code', label: '运单号', minWidth: 160, copyAction: 'copy' as const, copyValue: (row: any) => getWaybill(row), formatter: (row: any) => getWaybill(row) || '—' },
{ prop: 'wave_no', label: '波次号', minWidth: 140, copyAction: 'copy' as const },
@ -154,6 +154,10 @@ export const packingColumns = [
{ prop: 'sku_count', label: 'SKU数', width: 80 },
{ prop: 'pack_mode', label: '打包模式', width: 100 },
{ prop: 'status', label: '任务状态', width: 100 },
{ prop: 'express_info', label: '快递信息', minWidth: 140, formatter: (row: any) => getExpressInfo(row) },
{ prop: 'has_video', label: '包含录像', width: 90 },
{ prop: 'video_enable', label: '录像可用', width: 90 },
{ prop: 'videos', label: '录像', width: 110 },
// { prop: 'device_ids', label: '设备ID', width: 120, formatter: (row: any) => (row.device_ids || []).join(',') || '—' },
{ prop: 'remark', label: '备注', minWidth: 120 },
{ prop: 'start_time', label: '开始时间', width: 170, sortable: true, formatter: (row: any) => row.start_time ? dayjs(row.start_time).format('YYYY-MM-DD HH:mm:ss') : '—' },
@ -174,10 +178,7 @@ export const packingColumns = [
}},
{ prop: 'create_time', label: '创建时间', width: 170, sortable: true, formatter: (row: any) => row.create_time ? dayjs(row.create_time).format('YYYY-MM-DD HH:mm:ss') : '—' },
{ prop: 'update_time', label: '更新时间', width: 170, sortable: true, formatter: (row: any) => row.update_time ? dayjs(row.update_time).format('YYYY-MM-DD HH:mm:ss') : '—' },
{ prop: 'express_info', label: '快递信息', minWidth: 140, formatter: (row: any) => getExpressInfo(row) },
{ prop: 'has_video', label: '包含录像', width: 90 },
{ prop: 'video_enable', label: '录像可用', width: 90 },
{ prop: 'videos', label: '录像', width: 110 },
{ prop: 'operation', label: '操作', width: 180, fixed: 'right' }
]

View File

@ -296,6 +296,8 @@
:update-time="exportTaskProgress.updateTime"
/>
<!-- 按运单批量转入退件登记:已迁移到「运单管理」页(express/waybill)的卷栏按钮 -->
</div>
</template>
@ -492,9 +494,18 @@ const buttonLoadingMap = computed<Record<string, boolean>>(() => ({
loading: loading.value,
exportLoading: exportLoading.value,
}))
const buttonDisabledMap = ref<Record<string, boolean>>({})
const buttonLabelMap = ref<Record<string, string>>({})
const toolbarLayoutKey = ref('')
/** 勾选态驱动的按钮禁用(hasNoSelection:未勾选时禁用批量类操作) */
const buttonDisabledMap = computed<Record<string, boolean>>(() => ({
hasNoSelection: selectionRows.value.length === 0,
}))
const buttonLabelMap = computed<Record<string, string>>(() => ({}))
const toolbarLayoutKey = computed(() =>
JSON.stringify({
loading: buttonLoadingMap.value,
disabled: buttonDisabledMap.value,
labels: buttonLabelMap.value,
})
)
function resolveButtonLoading(loadingKey?: string) {
if (!loadingKey) return false

View File

@ -65,6 +65,13 @@ export const returnUnpackColumns = [
// { prop: 'id', label: 'ID', width: '80', sortable: 'custom' },
{ prop: 'unpack_no', label: '拆包单号', minWidth: '170', showOverflowTooltip: true, copyAction: 'copy' as const },
{ prop: 'waybill_code', label: '退回运单号', minWidth: '180', showOverflowTooltip: true, copyAction: 'copy' as const },
{
prop: 'order_express_id',
label: '原运单ID',
width: '110',
/** 为空 = 开单时未命中原单退回,不参与「运单批量转入」 */
formatter: (row: any) => (row?.order_express_id == null || row?.order_express_id === '' ? '-' : row.order_express_id),
},
{ prop: 'status', label: '拆包状态', width: '100' },
{ prop: 'detail_status', label: '明细状态', width: '110' },
{ prop: 'total_items', label: '物品种类', width: '90' },

View File

@ -0,0 +1,432 @@
<template>
<el-dialog
:model-value="visible"
title="运单批量转入退件登记"
width="760px"
align-center
:close-on-click-modal="false"
@update:model-value="handleVisibleChange"
@closed="resetState"
>
<!-- 确认态:入参 ids 取自勾选运单的 id(wms_order_express.id) -->
<template v-if="!result">
<el-alert class="transfer-alert" type="info" :closable="false" show-icon>
<template #title>
一个运单只允许一条有效拆包单:已存在未作废拆包单时会直接复用(不重复创建),已作废的会重新创建;子单(业务键 &gt; 1)会自动跳过;单条失败不影响其它运单。
</template>
</el-alert>
<div class="transfer-count">
<span>
已勾选 <b>{{ rows.length }}</b> 条,去重后待处理运单 <b>{{ submitIds.length }}</b> 条
</span>
<span class="transfer-count__limit">单次上限 {{ MAX_COUNT }} 条</span>
</div>
<el-alert
v-if="!submitIds.length"
class="transfer-alert"
type="warning"
:closable="false"
show-icon
>
<template #title>
所选行均缺少运单ID(运单表主键 id),无可用运单可提交;请重新勾选列表中的运单。
</template>
</el-alert>
<template v-else>
<div v-if="subRows.length" class="transfer-note">
其中 {{ subRows.length }} 条为子单(业务键 &gt; 1),将随 ids 一并提交,由服务端跳过并记入失败明细
</div>
<div v-if="blockedRows.length" class="transfer-note">
其中 {{ blockedRows.length }} 条缺少运单ID(id),不会提交
</div>
<div v-if="overLimit" class="transfer-error">
去重后 {{ submitIds.length }} 条已超过单次上限 {{ MAX_COUNT }} 条,请减少勾选后重试
</div>
</template>
<el-table :data="previewRows" size="small" border max-height="320" class="transfer-preview">
<el-table-column label="运单ID" width="100" align="center">
<template #default="{ row }">{{ row.waybill_id ?? '-' }}</template>
</el-table-column>
<el-table-column label="运单号" min-width="170" show-overflow-tooltip>
<template #default="{ row }">{{ row.waybill_code || '-' }}</template>
</el-table-column>
<el-table-column label="主单号" min-width="170" show-overflow-tooltip>
<template #default="{ row }">{{ row.main_waybill_code || '-' }}</template>
</el-table-column>
<el-table-column label="业务键" width="90" align="center">
<template #default="{ row }">{{ row.business_key ?? '-' }}</template>
</el-table-column>
<el-table-column label="能否转入" width="120" align="center">
<template #default="{ row }">
<el-tag size="small" :type="row.tagType">{{ row.tagText }}</el-tag>
</template>
</el-table-column>
</el-table>
<div class="transfer-note">
入参为运单表主键ID(id,去重后上限 200 条);归属仓库由服务端按当前登录仓库自动判定,无需选择仓库。
</div>
</template>
<!-- 结果态:接口逐单返回 success[] / failed[],HTTP 整体仍成功 -->
<template v-else>
<div class="transfer-summary">
<div class="transfer-summary__item">
<span class="transfer-summary__label">待处理运单</span>
<span class="transfer-summary__value">{{ result.total }}</span>
</div>
<div class="transfer-summary__item is-success">
<span class="transfer-summary__label">成功转入</span>
<span class="transfer-summary__value">{{ result.success_count }}</span>
</div>
<div class="transfer-summary__item" :class="{ 'is-danger': failedList.length > 0 }">
<span class="transfer-summary__label">失败</span>
<span class="transfer-summary__value">{{ result.failed_count }}</span>
</div>
</div>
<div v-if="successList.length" class="transfer-section">
<div class="transfer-section__title">成功明细({{ successList.length }})</div>
<el-table :data="successList" size="small" border max-height="240">
<el-table-column prop="waybill_id" label="运单ID" width="100" align="center" />
<el-table-column prop="waybill_code" label="退回运单号" min-width="170" show-overflow-tooltip />
<el-table-column prop="unpack_id" label="拆包单ID" width="100" align="center" />
<el-table-column prop="unpack_no" label="拆包单号" min-width="170" show-overflow-tooltip />
<el-table-column prop="detail_count" label="明细行数" width="95" align="center" />
<el-table-column prop="total_quantity" label="数量合计" width="95" align="center" />
<el-table-column label="处理结果" width="120" align="center">
<template #default="{ row }">
<el-tag size="small" :type="row.reused ? 'info' : 'success'">
{{ row.reused ? '已存在·复用' : '新转入' }}
</el-tag>
</template>
</el-table-column>
</el-table>
</div>
<div v-if="failedList.length" class="transfer-section">
<div class="transfer-section__title">
<span>失败明细({{ failedList.length }})</span>
<span class="transfer-section__actions">
<el-button link type="primary" size="small" @click="copyFailedCodes">复制失败运单号</el-button>
</span>
</div>
<el-table :data="failedList" size="small" border max-height="200">
<el-table-column label="运单ID" width="100" align="center">
<template #default="{ row }">{{ row.waybill_id ?? '-' }}</template>
</el-table-column>
<el-table-column label="退回运单号" min-width="170" show-overflow-tooltip>
<template #default="{ row }">{{ row.waybill_code || '-' }}</template>
</el-table-column>
<el-table-column prop="reason" label="失败原因" min-width="300" show-overflow-tooltip />
</el-table>
</div>
<div v-if="!successList.length && !failedList.length" class="transfer-empty">
<el-empty description="本次提交没有可处理的运单" :image-size="60" />
</div>
</template>
<template #footer>
<template v-if="!result">
<el-button size="small" :disabled="submitting" @click="handleVisibleChange(false)">取消</el-button>
<el-button
size="small"
type="primary"
:loading="submitting"
:disabled="!canSubmit"
@click="submit"
>
确认转入
</el-button>
</template>
<template v-else>
<el-button size="small" type="primary" @click="handleVisibleChange(false)">完成</el-button>
</template>
</template>
</el-dialog>
</template>
<script setup lang="ts">
import { computed, ref } from 'vue'
import { ElMessage } from 'element-plus'
import { returnUnpackTransferByWaybills } from '@/api/returnunpack'
import type {
ReturnUnpackTransferByWaybillsResponse,
ReturnUnpackTransferFailedItem,
ReturnUnpackTransferSuccessItem,
} from '@/api/returnunpack'
/**
* 运单批量转入退件登记(returnUnpack.transferByWaybills)
* 由「运单管理(express/waybill)」页面使用:勾选运单行 → 取 wms_order_express.id 作为入参 ids。
*/
/** 接口约定:ids 为运单表主键ID(wms_order_express.id),服务端 Number() 归一化 + 过滤非正整数 + 去重,去重后单次上限 200 */
const MAX_COUNT = 200
const props = withDefaults(
defineProps<{
visible: boolean
/** 勾选的运单行(取 id = wms_order_express.id 作为入参 ids) */
rows?: any[]
}>(),
{ rows: () => [] }
)
const emit = defineEmits<{
(e: 'update:visible', value: boolean): void
/** 提交成功(含部分失败)后触发,供父页面刷新列表 */
(e: 'success'): void
}>()
const submitting = ref(false)
const result = ref<ReturnUnpackTransferByWaybillsResponse | null>(null)
/** 运单表主键ID:仅正整数有效 */
function toWaybillId(value: unknown): number | null {
const id = Number(value)
return Number.isInteger(id) && id > 0 ? id : null
}
/** 子单判定:业务键 business_key > 1(文档口径:服务端跳过并记失败原因「运单为子单(business_key>1),跳过」) */
function isSubWaybill(value: unknown): boolean {
const key = Number(value)
return Number.isFinite(key) && key > 1
}
/** 确认列表行:逐条展示勾选运单并标注能否转入(同一运单重复勾选只保留一条) */
type PreviewRow = {
waybill_id: number | null
waybill_code: string
main_waybill_code: string
business_key: number | string | null
/** 子单(业务键 > 1):会一并提交,服务端跳过并记入 failed[] */
isSub: boolean
/** 有合法运单ID */
transferable: boolean
tagType: 'success' | 'info' | 'danger'
tagText: string
}
const previewRows = computed<PreviewRow[]>(() => {
const seen = new Set<number>()
const list: PreviewRow[] = []
props.rows.forEach((row) => {
const waybillId = toWaybillId(row?.id)
if (waybillId !== null) {
if (seen.has(waybillId)) return
seen.add(waybillId)
}
const sub = isSubWaybill(row?.business_key)
const transferable = waybillId !== null
const tagType: PreviewRow['tagType'] = !transferable ? 'danger' : sub ? 'info' : 'success'
const tagText = !transferable ? '缺少ID' : sub ? '子单·将跳过' : '可转入'
list.push({
waybill_id: waybillId,
waybill_code: String(row?.waybill_code ?? ''),
main_waybill_code: String(row?.main_waybill_code ?? ''),
business_key: row?.business_key ?? null,
isSub: sub,
transferable,
tagType,
tagText
})
})
return list
})
/**
* 待提交的运单主键ID(去重)
* 文档口径:ids 只做 Number() 归一化 + 过滤非正整数 + 去重,子单不在此处剔除,
* 由服务端跳过并写入 failed[](原因「运单为子单(business_key>1),跳过」),保证结果区与接口一致。
*/
const submitIds = computed<number[]>(() =>
previewRows.value
.filter((row) => row.transferable && row.waybill_id !== null)
.map((row) => row.waybill_id as number)
)
/** 缺少运单ID、不参与提交的勾选行 */
const blockedRows = computed(() => previewRows.value.filter((row) => !row.transferable))
/** 子单(业务键 > 1):提交后由服务端跳过并记入失败明细 */
const subRows = computed(() => previewRows.value.filter((row) => row.transferable && row.isSub))
const overLimit = computed(() => submitIds.value.length > MAX_COUNT)
const canSubmit = computed(() => submitIds.value.length > 0 && !overLimit.value && !submitting.value)
const successList = computed<ReturnUnpackTransferSuccessItem[]>(() => result.value?.success ?? [])
const failedList = computed<ReturnUnpackTransferFailedItem[]>(() => result.value?.failed ?? [])
function handleVisibleChange(next: boolean) {
emit('update:visible', next)
}
function resetState() {
result.value = null
submitting.value = false
}
async function submit() {
if (!canSubmit.value) return
submitting.value = true
try {
const res: any = await returnUnpackTransferByWaybills({ ids: submitIds.value })
if (!(res && (res.code === 1 || res.code === 200 || res.code === 20000 || res.flag === 'success'))) {
ElMessage.error(res?.message || '批量转入失败')
return
}
const payload = (res.data && typeof res.data === 'object' ? res.data : res) as ReturnUnpackTransferByWaybillsResponse
const success = Array.isArray(payload.success) ? payload.success : []
const failed = Array.isArray(payload.failed) ? payload.failed : []
result.value = {
total: Number(payload.total ?? success.length + failed.length),
success_count: Number(payload.success_count ?? success.length),
failed_count: Number(payload.failed_count ?? failed.length),
success,
failed,
}
const summary = `转入完成:成功 ${result.value.success_count} 条,失败 ${result.value.failed_count} 条`
if (result.value.failed_count > 0) {
ElMessage.warning(summary)
} else {
ElMessage.success(summary)
}
emit('success')
} catch {
// 请求层已统一提示错误
} finally {
submitting.value = false
}
}
async function copyFailedCodes() {
// 失败项运单号可能为空(运单未命中),此时回退到运单ID
const labels = failedList.value
.map((item) => item.waybill_code || (item.waybill_id != null ? `#${item.waybill_id}` : ''))
.filter(Boolean)
if (!labels.length) {
ElMessage.warning('没有可复制的失败运单')
return
}
const text = labels.join('\n')
try {
if (!navigator.clipboard?.writeText) throw new Error('no clipboard api')
await navigator.clipboard.writeText(text)
ElMessage.success(`已复制 ${labels.length} 个失败运单`)
} catch {
try {
const textarea = document.createElement('textarea')
textarea.value = text
textarea.setAttribute('readonly', 'readonly')
textarea.style.position = 'fixed'
textarea.style.left = '-9999px'
document.body.appendChild(textarea)
textarea.select()
document.execCommand('copy')
document.body.removeChild(textarea)
ElMessage.success(`已复制 ${labels.length} 个失败运单`)
} catch {
ElMessage.error('复制失败,请手动复制')
}
}
}
</script>
<style scoped lang="scss">
.transfer-alert {
margin-bottom: 12px;
:deep(.el-alert__title) {
line-height: 1.5;
}
}
.transfer-preview {
margin-top: 8px;
margin-bottom: 8px;
}
.transfer-count {
display: flex;
align-items: center;
gap: 12px;
margin-top: 6px;
font-size: 12px;
color: #606266;
.transfer-count__limit {
color: #909399;
}
b {
color: #409eff;
}
}
.transfer-error {
margin-top: 4px;
font-size: 12px;
color: #f56c6c;
}
.transfer-note {
margin-top: 4px;
font-size: 12px;
color: #909399;
}
.transfer-summary {
display: flex;
gap: 24px;
margin-bottom: 12px;
padding: 10px 14px;
border-radius: 4px;
background: #f5f7fa;
.transfer-summary__item {
display: flex;
align-items: baseline;
gap: 6px;
}
.transfer-summary__label {
font-size: 12px;
color: #909399;
}
.transfer-summary__value {
font-size: 18px;
font-weight: 600;
color: #303133;
}
.is-success .transfer-summary__value {
color: #67c23a;
}
.is-danger .transfer-summary__value {
color: #f56c6c;
}
}
.transfer-section {
& + .transfer-section {
margin-top: 12px;
}
.transfer-section__title {
display: flex;
align-items: center;
justify-content: space-between;
margin-bottom: 6px;
font-size: 13px;
color: #606266;
}
}
.transfer-empty {
padding: 8px 0;
}
</style>

View File

@ -827,6 +827,16 @@ export const TOOLBAR_BUTTONS: Record<string, ToolbarButtonConfig> = {
{ label: '导出全部', action: 'handleExportAll', divided: true }
]
},
transferByWaybills: {
key: 'transferByWaybills',
label: '转入退件登记',
category: 'function',
size: 'small',
type: 'primary',
plain: true,
disabledKey: 'noSelection',
action: 'openTransferByWaybillsDialog'
},
columnConfig: {
key: 'columnConfig',
label: '字段设置',

View File

@ -229,12 +229,12 @@
</div>
<!-- ===== 功能按钮表单(pages/ 目录下的组件) ===== -->
<!-- ★ 在此添加表单弹窗组件,如:
<YourFormDialog
v-model:visible="yourFormVisible"
@success="handleFormSuccess"
<!-- 运单批量转入退件登记(returnUnpack.transferByWaybills):入参取自勾选运单的 id -->
<TransferByWaybillsDialog
v-model:visible="transferByWaybillsVisible"
:rows="selectedRows"
@success="handleTransferByWaybillsSuccess"
/>
-->
<AsyncExportProgressDialog
v-model:visible="exportDialogVisible"
@ -264,6 +264,7 @@ import ScanBox from '@/components/ScanBox/index.vue'
import UpperTable from '@/components/UpperTable/index.vue'
import ColumnCellRenderer from './components/ColumnCellRenderer.vue'
import OperationCellRenderer from './components/OperationCellRenderer.vue'
import TransferByWaybillsDialog from './components/TransferByWaybillsDialog.vue'
import AsyncExportProgressDialog from '@/components/AsyncExportProgressDialog.vue'
import OrderToolbarButtonGroup from '@/views/order/orderManagement/component/OrderToolbarButtonGroup.vue'
import { waybillWarehouseDetail } from '@/api/waybill.warehouse'
@ -549,7 +550,8 @@ const toolbarActionMap: Record<string, () => void> = {
openColumnConfigPanel: () => { upperTableRef.value?.openColumnConfig?.() },
toggleDetailVisible: () => { detailVisible.value = !detailVisible.value },
handleExportSelected: () => { void handleExportSelected() },
handleExportAll: () => { void handleExportAll() }
handleExportAll: () => { void handleExportAll() },
openTransferByWaybillsDialog: () => { openTransferByWaybillsDialog() }
}
function handleToolbarButtonClick(action: string) {
@ -685,6 +687,25 @@ const handleSelectionChange = (rows: Record<string, any>[]) => {
selectedRows.value = rows
}
// ============================================================
// 运单批量转入退件登记(returnUnpack.transferByWaybills)
// ============================================================
const transferByWaybillsVisible = ref(false)
/** 运单批量转入:使用当前勾选的运单行(入参 ids 取运单表主键 id) */
function openTransferByWaybillsDialog() {
if (!selectedRows.value.length) {
ElMessage.warning('请先勾选需要转入退件登记的运单')
return
}
transferByWaybillsVisible.value = true
}
/** 转入后刷新列表(部分失败时也刷新,明细由弹窗结果区展示) */
function handleTransferByWaybillsSuccess() {
void loadData()
}
// ============================================================
// 明细面板
// ============================================================

View File

@ -429,5 +429,11 @@ function handleToolbarButtonClick(action: ToolbarButtonConfig['action']) {
<style scoped lang="scss">
@use "./styles/order-sub.scss";
/* 详情区外壳只保留左右 10px(订单明细/商品明细/订单日志面板自带 padding: 6px 10px 8px),
与 stock/external_stock 各面板保持一致 */
.order-sub-container .main-content .lower-level .detail-container {
padding: 0 10px;
}
</style>

View File

@ -2,43 +2,72 @@
<div class="order-items-detail" v-loading="loading">
<div v-if="!row?.id" class="empty-tip">请从上方列表中选择一项查看商品明细</div>
<template v-else>
<el-table :data="items" border stripe size="small" empty-text="暂无商品明细">
<el-table-column
v-for="column in activeColumns"
:key="column.prop"
:prop="column.prop"
:label="column.label"
:width="column.width"
:min-width="column.minWidth"
:align="column.align"
:show-overflow-tooltip="column.showOverflowTooltip"
<div ref="tableHostRef" class="table-host">
<el-table
ref="tableRef"
:data="pagedItems"
border
stripe
size="small"
style="width: 100%"
:height="tableHeight"
>
<template #default="{ row: item }">
<template v-if="column.image">
<template v-if="Array.isArray(item.images) && item.images.length">
<el-image
class="item-image"
:src="item.images[0]"
:preview-src-list="item.images"
preview-teleported
fit="cover"
/>
<el-table-column
v-for="column in activeColumns"
:key="column.prop"
:prop="column.prop"
:label="column.label"
:width="column.width"
:min-width="column.minWidth"
:align="column.align"
:show-overflow-tooltip="column.showOverflowTooltip"
>
<template #default="{ row: item }">
<template v-if="column.image">
<template v-if="Array.isArray(item.images) && item.images.length">
<el-image
class="item-image"
:src="item.images[0]"
:preview-src-list="item.images"
preview-teleported
fit="cover"
/>
</template>
<span v-else class="cell-empty">—</span>
</template>
<template v-else>
{{ formatCellValue(item, column) }}
</template>
<span v-else class="cell-empty">—</span>
</template>
<template v-else>
{{ formatCellValue(item, column) }}
</template>
</el-table-column>
<template #empty>
<div class="empty-tip">暂无商品明细</div>
</template>
</el-table-column>
</el-table>
</el-table>
</div>
<div class="pagination-container">
<el-pagination
v-model:current-page="pagination.page"
v-model:page-size="pagination.pageSize"
:page-sizes="[10, 20, 50, 100]"
:total="pagination.total"
layout="total, sizes, prev, pager, next, jumper"
background
size="small"
@size-change="handlePageSizeChange"
@current-change="handlePageChange"
/>
</div>
</template>
</div>
</template>
<script setup lang="ts">
import { computed, onBeforeUnmount, ref, watch } from 'vue'
import { computed, nextTick, onBeforeUnmount, reactive, ref, watch } from 'vue'
import { ElMessage } from 'element-plus'
import { useResizeObserver } from '@vueuse/core'
import { orderPendingOrder } from '@/api/order.pendingorder/orderpendingOrder'
import {
formatOrderTime,
@ -72,6 +101,49 @@ const activeColumns = computed(() => {
return props.compactColumns ?? orderItemCompactColumns
})
/* 表格高度:由容器实际高度驱动(Element Plus 不支持 height="100%") */
const tableHostRef = ref<HTMLElement | null>(null)
const tableRef = ref<any>(null)
const tableHeight = ref(220)
/* 商品明细随订单明细接口一次性返回,所以用前端分页(交互对齐 stock/external_stock「外部绑定」) */
const pagination = reactive({
page: 1,
pageSize: 20,
total: 0
})
/** 当前页商品明细 */
const pagedItems = computed(() => {
const start = (pagination.page - 1) * pagination.pageSize
return items.value.slice(start, start + pagination.pageSize)
})
useResizeObserver(tableHostRef, (entries) => {
const h = entries[0]?.contentRect.height ?? 0
if (h >= 100) {
tableHeight.value = Math.floor(h)
}
})
function handlePageChange(page: number) {
pagination.page = page
resetTableScroll()
}
function handlePageSizeChange(pageSize: number) {
pagination.pageSize = pageSize
pagination.page = 1
resetTableScroll()
}
/** 切页后把表格滚动位置归零 */
function resetTableScroll() {
nextTick(() => {
tableRef.value?.setScrollTop?.(0)
})
}
function formatAmount(value: unknown) {
if (value === null || value === undefined || value === '') return '-'
const n = Number(value)
@ -112,6 +184,7 @@ function formatCellValue(row: Record<string, any>, column: OrderItemColumnConfig
async function loadItems() {
if (!props.row?.id) {
items.value = []
pagination.total = 0
return
}
loading.value = true
@ -134,6 +207,7 @@ async function loadItems() {
ElMessage.error('获取商品明细失败')
items.value = []
} finally {
pagination.total = items.value.length
loading.value = false
}
}
@ -141,6 +215,7 @@ async function loadItems() {
watch(
() => props.row?.id,
() => {
pagination.page = 1
loadItems()
},
{ immediate: true }
@ -152,11 +227,40 @@ onBeforeUnmount(() => {
</script>
<style scoped lang="scss">
/* 新设计(对齐 stock/external_stock「外部绑定」):面板自带内边距 + 表格自适应高度 + 右下角前端分页 */
.order-items-detail {
width: 100%;
height: 100%;
overflow-y: auto;
padding: 10px;
padding: 6px 10px 8px;
box-sizing: border-box;
background: #fff;
display: flex;
flex-direction: column;
overflow: hidden;
}
.order-items-detail .table-host {
flex: 1;
min-height: 120px;
min-width: 0;
overflow: hidden;
}
.order-items-detail .pagination-container {
flex-shrink: 0;
display: flex;
justify-content: flex-end;
align-items: center;
margin-top: 6px;
/* 每页条数下拉框与 UpperTable 的分页器保持一致 */
:deep(.el-select--small) {
width: 80px;
}
:deep(.el-input__wrapper) {
padding: 0 4px;
}
}
.item-image {
@ -181,4 +285,11 @@ onBeforeUnmount(() => {
color: #909399;
font-size: 13px;
}
/* 表格内部空态(#empty 插槽):表格已知高度,交给 el-table 自身居中即可 */
.order-items-detail .table-host .empty-tip {
height: auto;
display: block;
line-height: 1.5;
}
</style>

View File

@ -229,20 +229,29 @@ onBeforeUnmount(() => {
<style scoped lang="scss">
@use "../styles/order-sub.scss";
/* 新设计(对齐 stock/external_stock「基本信息」):面板自带内边距 + 分区标题左侧蓝竖条 + label 浅灰底 */
.pending-order-detail {
padding: 10px;
min-height: 100%;
padding: 6px 10px 8px;
box-sizing: border-box;
}
.section {
margin-bottom: 12px;
&:last-child {
margin-bottom: 0;
}
}
.section-title {
margin-bottom: 8px;
color: #606266;
font-size: 13px;
margin-bottom: 10px;
padding-left: 8px;
border-left: 3px solid #409eff;
color: #303133;
font-size: 14px;
font-weight: 600;
line-height: 1.4;
}
.detail-descriptions {
@ -260,6 +269,8 @@ onBeforeUnmount(() => {
:deep(.el-descriptions__label) {
width: 110px;
min-width: 110px;
background: #fafbfc;
font-weight: 500;
}
:deep(.el-descriptions__content) {

View File

@ -1,25 +1,27 @@
<template>
<div class="log-container">
<el-button-group class="toolbar-btn-group">
<el-button
type="primary"
size="small"
title="刷新"
:loading="loading"
class="toolbar-btn"
:disabled="!orderId"
@click="handleRefresh"
>
刷新
</el-button>
</el-button-group>
<div class="header-actions">
<div class="left-actions">
<el-button
size="small"
type="primary"
:loading="loading"
:disabled="!orderId"
@click="handleRefresh"
>
刷新
</el-button>
</div>
</div>
<div ref="tableHostRef" class="table-host">
<el-table
:data="tableData"
border
stripe
style="width: 100%; height: 100%"
height="100%"
size="small"
style="width: 100%"
:height="tableHeight"
v-loading="loading"
>
<el-table-column prop="created_at" label="时间" width="175" />
@ -66,7 +68,12 @@
<span v-else class="cell-muted">—</span>
</template>
</el-table-column>
<template #empty>
<div class="empty-tip">暂无订单日志</div>
</template>
</el-table>
</div>
<div class="pagination-container">
<el-pagination
@ -95,9 +102,9 @@
</template>
<script setup lang="ts">
import { computed, reactive, ref, watch } from 'vue'
import { computed, nextTick, reactive, ref, watch } from 'vue'
import { ElMessage } from 'element-plus'
import { Refresh } from '@element-plus/icons-vue'
import { useResizeObserver } from '@vueuse/core'
import RequestData from '@/components/RequestData/index.vue'
import { orderQueryOrderLogs } from '@/api/order.index/orderindex'
@ -119,6 +126,25 @@ const pagination = reactive({
total: 0
})
/* 表格高度:由容器实际高度驱动(Element Plus 不支持 height="100%") */
const tableHostRef = ref<HTMLElement | null>(null)
const tableRef = ref<any>(null)
const tableHeight = ref(220)
useResizeObserver(tableHostRef, (entries) => {
const h = entries[0]?.contentRect.height ?? 0
if (h >= 100) {
tableHeight.value = Math.floor(h)
}
})
/** 切页后把表格滚动位置归零 */
function resetTableScroll() {
nextTick(() => {
tableRef.value?.setScrollTop?.(0)
})
}
const orderId = computed(() => {
const id = props.data?.id
if (id === undefined || id === null || id === '') return ''
@ -173,12 +199,14 @@ watch(
async function handlePageChange(page: number) {
pagination.page = page
resetTableScroll()
await loadOrderLogs()
}
async function handlePageSizeChange(pageSize: number) {
pagination.pageSize = pageSize
pagination.page = 1
resetTableScroll()
await loadOrderLogs()
}
@ -223,17 +251,46 @@ function viewData(row: any) {
</script>
<style scoped lang="scss">
/* 新设计(对齐 stock/external_stock「日志 / 外部绑定」):面板自带内边距 +
header-actions 按钮行(间距 6px) + 表格自适应剩余高度 + 右下角分页 */
.log-container {
width: 100%;
height: 100%;
padding: 8px 10px;
padding: 6px 10px 8px;
overflow: hidden;
display: flex;
flex-direction: column;
background: #fff;
box-sizing: border-box;
}
.toolbar-btn-group {
margin-bottom: 5px;
.header-actions {
display: flex;
justify-content: space-between;
align-items: center;
margin-bottom: 6px;
flex-shrink: 0;
gap: 4px;
flex-wrap: wrap;
}
.left-actions {
display: flex;
align-items: center;
gap: 6px;
/* 清除 Element Plus 默认按钮左边距,统一由 gap 控制等间距 */
:deep(.el-button) {
margin-left: 0;
margin-right: 0;
}
}
.table-host {
flex: 1;
min-height: 120px;
min-width: 0;
overflow: hidden;
}
.cell-muted {
@ -241,41 +298,27 @@ function viewData(row: any) {
font-size: 12px;
}
.el-table {
flex: 1;
.empty-tip {
text-align: center;
font-size: 13px;
line-height: 1.5;
}
.pagination-container {
flex-shrink: 0;
display: flex;
justify-content: flex-end;
align-items: center;
padding: 5px 10px;
border-top: 1px solid #e8e8e8;
background: #fff;
flex-shrink: 0;
}
margin-top: 6px;
.pagination-container :deep(.el-pagination) {
--el-pagination-button-width: 28px;
--el-pagination-button-height: 28px;
font-size: 12px;
}
/* 每页条数下拉框与 UpperTable 的分页器保持一致 */
:deep(.el-select--small) {
width: 80px;
}
.pagination-container :deep(.el-pagination .el-select .el-input__wrapper) {
min-height: 24px;
}
.pagination-container :deep(.btn-prev),
.pagination-container :deep(.btn-next),
.pagination-container :deep(.el-pager li) {
border-radius: 4px;
color: #606266;
}
.pagination-container :deep(.el-pager li.is-active) {
color: #409eff;
font-weight: 600;
background: #ffffff;
:deep(.el-input__wrapper) {
padding: 0 4px;
}
}
:deep(.el-drawer__body) {

View File

@ -154,11 +154,15 @@ export const COMMON_TRANSLATIONS: Record<string, Record<string, string>> = {
'3': '小团购',
'4': '单品单件'
},
/** 订单来源渠道 create_channel:枚举与标签见 orderCreateChannelFilterOptions;
* 列表响应已由后端输出中文标签,此处映射仅作兜底(兼容历史英文值与旧枚举)。 */
create_channel: {
'MANUAL': '手工单',
'API': '接口',
'QM': '奇门',
'API': 'API',
'STOCKOUT': '出库转单',
// 历史枚举(后端已不再返回,保留兼容)
'IMPORT': '导入',
'MANUAL': '手动',
'PLATFORM': '平台'
}
}
@ -1227,6 +1231,14 @@ export const buyerMessageHasFilterOptions = [
{ label: '无留言', value: 'none' },
]
/** 订单来源渠道(订单表 create_channel 列):查询必须传英文枚举值;列表响应已由后端格式化为中文标签(手工单/接口/奇门/出库转单) */
export const orderCreateChannelFilterOptions = [
{ label: '手工单', value: 'MANUAL' },
{ label: '接口', value: 'API' },
{ label: '奇门', value: 'QM' },
{ label: '出库转单', value: 'STOCKOUT' },
]
export const syncStatusFilterOptionsBasic = [
{ label: '待同步', value: 'padding' },
{ label: '已同步', value: 'fin' },
@ -1383,7 +1395,7 @@ export const waveIndexRangeScanField = scanBasicField({
hideOperator: true
})
/** ScanBox:波次类型(wave_scope)。0=未分配、1=大团购、2=散单、3=小团购、4=单品单件;
* 后端按值解析波次ID 范围(未分配 wave_id = 0,其余按 wave_type 反查波次ID),多选由后端 OR 合并。 */
* 后端直接按订单表 wave_scope 列过滤,支持单值(eq)、多选(in)与 { operator, value } 标准结构。 */
export const waveScopeScanField = scanBasicField({
label: '波次类型',
value: 'wave_scope',
@ -1409,6 +1421,14 @@ export const exceptionOrderCodeScanField = scanBasicField({ label: '发货单号
export const shopNickScanField = scanBasicField({ label: '店铺名称', value: 'shop_nick', type: 'text' })
export const sysPlatformNameScanField = scanBasicField({ label: '平台', value: 'sys_platform_name', type: 'select', options: [] })
export const sysPlatformCodeScanField = scanBasicField({ label: '平台编码', value: 'sys_platform_name', type: 'select', options: [] })
/** ScanBox:订单来源(create_channel)。后端按订单表 create_channel 列过滤;多选输出 { operator: 'in', value: [...] },单值走 eq */
export const createChannelScanField = scanBasicField({
label: '来源',
value: 'create_channel',
type: 'select',
multiple: true,
options: orderCreateChannelFilterOptions
})
export const buyerNickScanField = scanBasicField({ label: '买家昵称', value: 'buyer_nick', type: 'text' })
export const receiverNameScanField = scanBasicField({ label: '收件人', value: 'name', type: 'text' })
export const receiverMobileScanField = scanBasicField({ label: '电话', value: 'mobile', type: 'text' })
@ -1599,6 +1619,7 @@ export const deliveryAvailableFields = [
{ ...orderFlagScanField, group: SCAN_ORDER_INFO_GROUP },
{ ...shopNickScanField, group: SCAN_ORDER_INFO_GROUP },
{ ...sysPlatformNameScanField, group: SCAN_ORDER_INFO_GROUP },
{ ...createChannelScanField, group: SCAN_ORDER_INFO_GROUP },
{ ...logisticsNameScanField, group: SCAN_ORDER_INFO_GROUP },
{ ...expressCompanyScanField, group: SCAN_ORDER_INFO_GROUP },
{ ...stockQueryScanField, group: SCAN_ORDER_INFO_GROUP },
@ -1795,6 +1816,7 @@ export const reviewAvailableFields = [
{ ...sourceOrderCodesScanField, group: SCAN_ORDER_INFO_GROUP },
{ ...shopNickScanField, group: SCAN_ORDER_INFO_GROUP },
{ ...sysPlatformCodeScanField, group: SCAN_ORDER_INFO_GROUP },
{ ...createChannelScanField, group: SCAN_ORDER_INFO_GROUP },
{ ...expressCompanyScanField, group: SCAN_ORDER_INFO_GROUP },
{ ...stockQueryScanField, group: SCAN_ORDER_INFO_GROUP },
// 商品统计
@ -1960,6 +1982,7 @@ export const pendingAvailableFields = [
{ ...orderFlagScanField, group: SCAN_ORDER_INFO_GROUP },
{ ...shopNickScanField, group: SCAN_ORDER_INFO_GROUP },
{ ...sysPlatformNameScanField, group: SCAN_ORDER_INFO_GROUP },
{ ...createChannelScanField, group: SCAN_ORDER_INFO_GROUP },
{ ...logisticsNameScanField, group: SCAN_ORDER_INFO_GROUP },
{ ...expressCompanyScanField, group: SCAN_ORDER_INFO_GROUP },
{ ...stockQueryScanField, group: SCAN_ORDER_INFO_GROUP },
@ -2348,6 +2371,7 @@ export const expectionOrderAvailableFields = [
{ ...expressCodeScanField, group: SCAN_ORDER_INFO_GROUP },
{ ...sourceOrderCodesScanField, group: SCAN_ORDER_INFO_GROUP },
{ ...orderFlagScanField, group: SCAN_ORDER_INFO_GROUP },
{ ...createChannelScanField, group: SCAN_ORDER_INFO_GROUP },
{ ...logisticsNameScanField, group: SCAN_ORDER_INFO_GROUP },
{ ...expressCompanyScanField, group: SCAN_ORDER_INFO_GROUP },
{ ...stockQueryScanField, group: SCAN_ORDER_INFO_GROUP },
@ -2471,6 +2495,7 @@ export const archiveAvailableFields = [
{ ...waveScopeScanField, group: SCAN_ORDER_INFO_GROUP },
{ ...sourceOrderCodesScanField, group: SCAN_ORDER_INFO_GROUP },
{ ...shopNickScanField, group: SCAN_ORDER_INFO_GROUP },
{ ...createChannelScanField, group: SCAN_ORDER_INFO_GROUP },
{ ...expressCompanyScanField, group: SCAN_ORDER_INFO_GROUP },
{ ...stockQueryScanField, group: SCAN_ORDER_INFO_GROUP },
// 商品统计

View File

@ -424,4 +424,10 @@ function handleToolbarButtonClick(action: ToolbarButtonConfig['action']) {
<style scoped lang="scss">
@use "./styles/order-sub.scss";
/* 详情区外壳只保留左右 10px(订单明细/商品明细/订单日志面板自带 padding: 6px 10px 8px),
与 stock/external_stock 各面板保持一致 */
.order-sub-container .main-content .lower-level .detail-container {
padding: 0 10px;
}
</style>

View File

@ -722,6 +722,12 @@ function handleToolbarButtonClick(action: ToolbarButtonConfig['action']) {
<style scoped lang="scss">
@use "./styles/order-sub.scss";
/* 详情区外壳只保留左右 10px(订单明细/商品明细/订单日志面板自带 padding: 6px 10px 8px),
与 stock/external_stock 各面板保持一致 */
.order-sub-container .main-content .lower-level .detail-container {
padding: 0 10px;
}
.detail-page {
height: 100%;
overflow-x: hidden;

View File

@ -424,4 +424,10 @@ function handleToolbarButtonClick(action: ToolbarButtonConfig['action']) {
<style scoped lang="scss">
@use "./styles/order-sub.scss";
/* 详情区外壳只保留左右 10px(订单明细/商品明细/订单日志面板自带 padding: 6px 10px 8px),
与 stock/external_stock 各面板保持一致 */
.order-sub-container .main-content .lower-level .detail-container {
padding: 0 10px;
}
</style>

View File

@ -1154,6 +1154,12 @@ function onBatchPrintSuccess() {
margin: 4px 0;
}
/* 详情区外壳只保留左右 10px(订单明细/商品明细/订单日志面板自带 padding: 6px 10px 8px),
与 stock/external_stock 各面板保持一致 */
.order-sub-container .main-content .lower-level .detail-container {
padding: 0 10px;
}
.detail-page {
height: 100%;
overflow-x: hidden;

View File

@ -535,6 +535,12 @@ function handleToolbarButtonClick(action: ToolbarButtonConfig['action']) {
margin-bottom: 12px;
}
/* 详情区外壳只保留左右 10px(订单明细/商品明细/订单日志面板自带 padding: 6px 10px 8px),
与 stock/external_stock 各面板保持一致 */
.order-sub-container .main-content .lower-level .detail-container {
padding: 0 10px;
}
.detail-page {
height: 100%;
overflow-x: hidden;

View File

@ -1110,6 +1110,12 @@ async function handleConfirmInterceptBatch() {
<style scoped lang="scss">
@use "./styles/order-sub.scss";
/* 详情区外壳只保留左右 10px(订单明细/商品明细/订单日志面板自带 padding: 6px 10px 8px),
与 stock/external_stock 各面板保持一致 */
.order-sub-container .main-content .lower-level .detail-container {
padding: 0 10px;
}
.detail-page {
height: 100%;
overflow-x: hidden;

View File

@ -545,6 +545,12 @@ async function handleSingleReview() {
<style scoped lang="scss">
@use "./styles/order-sub.scss";
/* 详情区外壳只保留左右 10px(订单明细/商品明细/订单日志面板自带 padding: 6px 10px 8px),
与 stock/external_stock 各面板保持一致 */
.order-sub-container .main-content .lower-level .detail-container {
padding: 0 10px;
}
.detail-page {
height: 100%;
overflow-x: hidden;

View File

@ -416,7 +416,7 @@ export function buildOrderWhereConditions(rawConditions: Record<string, any>) {
value: condition
}
})
// 波次类型 wave_scope:单值归一为标量 eq,多值保留数组(后端按 wave_type 反查波次ID 后 OR 合并)
// 波次类型 wave_scope:单值归一为 eq,多值保留数组(后端直接按订单表 wave_scope 列过滤,多值走 in)
if (where.wave_scope && typeof where.wave_scope === 'object' && 'value' in where.wave_scope) {
const rawValue = (where.wave_scope as { value: unknown }).value
const value = Array.isArray(rawValue) && rawValue.length === 1 ? rawValue[0] : rawValue

View File

@ -3997,8 +3997,9 @@ async function submitFallbackOrderFetchByIds() {
<style scoped lang="scss">
@use "../orderManagement/styles/order-sub.scss";
/* 详情区外壳不留上/下间距(波次明细组件自带 padding: 6px 10px 8px),只留左右 10px */
.order-sub-container .main-content .lower-level .detail-container {
padding: 10px;
padding: 0 10px;
overflow: auto;
}

View File

@ -2785,8 +2785,9 @@ async function submitGroupOrderDialog() {
<style scoped lang="scss">
@use "../orderManagement/styles/order-sub.scss";
/* 详情区外壳不留上/下间距(波次明细组件自带 padding: 6px 10px 8px),只留左右 10px */
.order-sub-container .main-content .lower-level .detail-container {
padding: 10px;
padding: 0 10px;
overflow: auto;
}

View File

@ -183,49 +183,69 @@
</el-tabs>
</div>
<div class="detail-container">
<div v-if="detailActiveTab === 'waveList'" class="detail-page order-detail-wrapper">
<el-table
v-if="selectedTaskWaveList.length"
:data="selectedTaskWaveList"
border
size="small"
height="100%"
>
<el-table-column label="波次号" min-width="180" show-overflow-tooltip>
<template #default="{ row: waveRow }">
<span
class="click-copy-link"
role="button"
tabindex="0"
title="点击复制波次号"
@click.stop="copyWaveNo(waveRow.wave_no)"
@keydown.enter.prevent="copyWaveNo(waveRow.wave_no)"
>
{{ waveRow.wave_no || '—' }}
</span>
<div v-if="detailActiveTab === 'waveList'" class="detail-page wave-list-panel">
<div ref="waveTableHostRef" class="table-host">
<el-table
ref="waveTableRef"
:data="pagedTaskWaveList"
border
stripe
size="small"
style="width: 100%"
:height="waveTableHeight"
>
<el-table-column label="波次号" min-width="180" show-overflow-tooltip>
<template #default="{ row: waveRow }">
<span
class="click-copy-link"
role="button"
tabindex="0"
title="点击复制波次号"
@click.stop="copyWaveNo(waveRow.wave_no)"
@keydown.enter.prevent="copyWaveNo(waveRow.wave_no)"
>
{{ waveRow.wave_no || '—' }}
</span>
</template>
</el-table-column>
<el-table-column prop="wave_id" label="波次ID" width="100" align="center" />
<el-table-column prop="box_no" label="箱号" width="80" align="center" />
<el-table-column label="状态" width="100" align="center">
<template #default="{ row: waveRow }">
<span :class="getStatusTextClass(getWaveStatusTagType(waveRow.status))">
{{ getWaveStatusText(waveRow.status) }}
</span>
</template>
</el-table-column>
<el-table-column label="绑定时间" min-width="168" show-overflow-tooltip>
<template #default="{ row: waveRow }">
{{ formatWaveTime(waveRow.bind_time) }}
</template>
</el-table-column>
<el-table-column label="拣货时间" min-width="168" show-overflow-tooltip>
<template #default="{ row: waveRow }">
{{ formatWaveTime(waveRow.pick_time) }}
</template>
</el-table-column>
<template #empty>
<div class="empty-tip">该任务暂无关联波次</div>
</template>
</el-table-column>
<el-table-column prop="wave_id" label="波次ID" width="100" align="center" />
<el-table-column prop="box_no" label="箱号" width="80" align="center" />
<el-table-column label="状态" width="100" align="center">
<template #default="{ row: waveRow }">
<span :class="getStatusTextClass(getWaveStatusTagType(waveRow.status))">
{{ getWaveStatusText(waveRow.status) }}
</span>
</template>
</el-table-column>
<el-table-column label="绑定时间" min-width="168" show-overflow-tooltip>
<template #default="{ row: waveRow }">
{{ formatWaveTime(waveRow.bind_time) }}
</template>
</el-table-column>
<el-table-column label="拣货时间" min-width="168" show-overflow-tooltip>
<template #default="{ row: waveRow }">
{{ formatWaveTime(waveRow.pick_time) }}
</template>
</el-table-column>
</el-table>
<el-empty v-else description="该任务暂无关联波次" />
</el-table>
</div>
<div class="pagination-container">
<el-pagination
v-model:current-page="wavePagination.page"
v-model:page-size="wavePagination.pageSize"
:page-sizes="[10, 20, 50, 100]"
:total="wavePagination.total"
layout="total, sizes, prev, pager, next, jumper"
background
size="small"
@size-change="handleWavePageSizeChange"
@current-change="handleWavePageChange"
/>
</div>
</div>
</div>
</div>
@ -241,8 +261,9 @@
</template>
<script setup lang="ts">
import { computed, onMounted, reactive, ref, watch } from 'vue'
import { computed, nextTick, onMounted, reactive, ref, watch } from 'vue'
import { ElMessage, ElMessageBox } from 'element-plus'
import { useResizeObserver } from '@vueuse/core'
import ScanBox from '@/components/ScanBox/index.vue'
import UpperTable from '@/components/UpperTable/index.vue'
import OrderToolbarButtonGroup from '@/views/order/orderManagement/component/OrderToolbarButtonGroup.vue'
@ -707,6 +728,63 @@ const selectedTaskWaveList = computed(() => {
return Array.isArray(waves) ? waves : []
})
// ============================================================
// 波次列表分页(波次随任务行一次性返回,所以用前端分页;
// 交互与 stock/external_stock「外部绑定」erpStock.vue 一致)
// ============================================================
const waveTableHostRef = ref<HTMLElement | null>(null)
const waveTableRef = ref<any>(null)
/** 表格高度:由容器实际高度驱动(Element Plus 不支持 height="100%") */
const waveTableHeight = ref(200)
const wavePagination = reactive({
page: 1,
pageSize: 20,
total: 0
})
/** 当前页波次 */
const pagedTaskWaveList = computed(() => {
const start = (wavePagination.page - 1) * wavePagination.pageSize
return selectedTaskWaveList.value.slice(start, start + wavePagination.pageSize)
})
useResizeObserver(waveTableHostRef, (entries) => {
const h = entries[0]?.contentRect.height ?? 0
if (h >= 100) {
waveTableHeight.value = Math.floor(h)
}
})
/** 切任务/刷新后波次数量会变:同步总数并回到第 1 页 */
watch(
selectedTaskWaveList,
(rows) => {
wavePagination.total = rows.length
wavePagination.page = 1
resetWaveTableScroll()
},
{ immediate: true }
)
function handleWavePageChange(page: number) {
wavePagination.page = page
resetWaveTableScroll()
}
function handleWavePageSizeChange(pageSize: number) {
wavePagination.pageSize = pageSize
wavePagination.page = 1
resetWaveTableScroll()
}
/** 切页后把表格滚动位置归零 */
function resetWaveTableScroll() {
nextTick(() => {
waveTableRef.value?.setScrollTop?.(0)
})
}
function handleRowClick(row: Record<string, any>) {
const id = getTaskId(row)
if (!id) return
@ -1108,44 +1186,48 @@ onMounted(() => {
}
}
/* 与 UpperTable 底部分页条一致 */
.pagination-container {
padding: 5px 10px;
border-top: 1px solid #e8e8e8;
background: #fff;
/* 波次列表面板(新设计:面板自带内边距 + 表格自适应高度 + 右下角前端分页,
与 stock/external_stock「外部绑定」erpStock.vue 完全一致) */
.wave-list-panel {
width: 100%;
height: 100%;
flex: 1;
min-height: 0;
display: flex;
flex-direction: row;
justify-content: space-between;
flex-direction: column;
padding: 6px 10px 8px;
box-sizing: border-box;
background: #fff;
overflow: hidden;
}
/* 详情区外壳:不留上/下间距(面板自带 padding: 6px 10px 8px),只保留左右 10px
—— 与 external_stock/index.vue 的 .detail-container 一致(否则表格比「外部绑定」多贴边 10px) */
.order-sub-container .main-content .lower-level .detail-container {
padding: 0 10px;
overflow: hidden;
}
.wave-list-panel .table-host {
flex: 1;
min-height: 120px;
min-width: 0;
overflow: hidden;
}
.wave-list-panel .pagination-container {
margin-top: 6px;
display: flex;
justify-content: flex-end;
align-items: center;
flex-wrap: wrap;
flex-shrink: 0;
}
.pagination-container .pagination-info {
font-size: 12px;
color: #606266;
white-space: nowrap;
}
.pagination-container :deep(.el-pagination__sizes),
.pagination-container :deep(.el-pagination__jump),
.pagination-container :deep(.el-pagination__total) {
display: inline-flex !important;
margin-right: 8px;
}
.pagination-container :deep(.el-pagination) {
flex-wrap: wrap;
justify-content: flex-end;
--el-pagination-button-width: 28px;
--el-pagination-button-height: 28px;
}
.pagination-container :deep(.el-select--small) {
.wave-list-panel .pagination-container :deep(.el-select--small) {
width: 80px;
}
.pagination-container :deep(.el-input__wrapper) {
.wave-list-panel .pagination-container :deep(.el-input__wrapper) {
padding: 0 4px;
}

View File

@ -29,8 +29,8 @@
</span>
</el-descriptions-item>
<el-descriptions-item label="创建人">{{ row.creator || row.creator_name || '—' }}</el-descriptions-item>
<el-descriptions-item label="商品类型">{{ row.item_part_type || '—' }}</el-descriptions-item>
<el-descriptions-item label="商品部位">{{ row.item_part || '—' }}</el-descriptions-item>
<el-descriptions-item label="商品类型" :span="2">{{ row.item_part_type || '—' }}</el-descriptions-item>
<el-descriptions-item label="商品部位" :span="2">{{ row.item_part || '—' }}</el-descriptions-item>
<el-descriptions-item label="商品结构" :span="4">{{ row.item_detail_machine || row.item_detail || '—' }}</el-descriptions-item>
</el-descriptions>
</div>
@ -212,28 +212,39 @@ function formatDateTime(value: string | number | null | undefined) {
<style scoped lang="scss">
@use "../../orderManagement/styles/order-sub.scss";
/* 面板自带内边距(宿主 .detail-container 已改为 padding: 0 10px),
分区标题 / label 样式对齐 stock/external_stock「基本信息」新设计 */
.wave-batch-detail {
height: 100%;
overflow-y: auto;
padding: 10px;
padding: 6px 10px 8px;
box-sizing: border-box;
}
.section {
margin-bottom: 12px;
&:last-child {
margin-bottom: 0;
}
}
.section-title {
margin-bottom: 8px;
color: #606266;
font-size: 13px;
font-size: 14px;
font-weight: 600;
color: #303133;
margin-bottom: 10px;
padding-left: 8px;
border-left: 3px solid #409eff;
line-height: 1.4;
}
.detail-descriptions {
:deep(.el-descriptions__label) {
width: 110px;
min-width: 110px;
background: #fafbfc;
font-weight: 500;
}
:deep(.el-descriptions__content) {

View File

@ -123,59 +123,89 @@
</div>
<div class="detail-container">
<el-descriptions v-if="activeTab === 'info'" :column="2" border size="small">
<el-descriptions-item label="商品编码">{{ selectedRow.item_code || '—' }}</el-descriptions-item>
<el-descriptions-item label="商品名称">{{ selectedRow.item_name || '—' }}</el-descriptions-item>
<el-descriptions-item label="商家编码">{{ selectedRow.goods_code || '—' }}</el-descriptions-item>
<el-descriptions-item label="品牌">{{ selectedRow.brand_name || '—' }}</el-descriptions-item>
<el-descriptions-item label="库存单位">{{ selectedRow.stock_unit || '—' }}</el-descriptions-item>
<el-descriptions-item label="毛重">{{ selectedRow.gross_weight != null ? selectedRow.gross_weight + 'g' : '—' }}</el-descriptions-item>
<el-descriptions-item label="条码" :span="2">
<template v-if="selectedRow.barcodes && selectedRow.barcodes.length">
<el-tag
v-for="(bc, idx) in selectedRow.barcodes"
:key="idx"
size="small"
style="margin-right: 4px; margin-bottom: 2px"
>{{ bc }}</el-tag>
</template>
<span v-else>—</span>
</el-descriptions-item>
<el-descriptions-item label="序列号管理">
<span :class="getStatusTextClass(selectedRow.is_sn_mgmt === 'Y' ? 'success' : 'info')">
{{ selectedRow.is_sn_mgmt === 'Y' ? '是' : '否' }}
</span>
</el-descriptions-item>
<el-descriptions-item label="效期管理">
<span :class="getStatusTextClass(selectedRow.is_shelf_life_mgmt === 'Y' ? 'success' : 'info')">
{{ selectedRow.is_shelf_life_mgmt === 'Y' ? '是' : '否' }}
</span>
</el-descriptions-item>
<el-descriptions-item label="批次管理">
<span :class="getStatusTextClass(selectedRow.is_batch_mgmt === 'Y' ? 'success' : 'info')">
{{ selectedRow.is_batch_mgmt === 'Y' ? '是' : '否' }}
</span>
</el-descriptions-item>
<el-descriptions-item label="打包要求" :span="2">{{ selectedRow.packing_requirements || '—' }}</el-descriptions-item>
<el-descriptions-item label="创建时间">{{ selectedRow.create_at_display || '—' }}</el-descriptions-item>
<el-descriptions-item label="更新时间">{{ selectedRow.update_at_display || '—' }}</el-descriptions-item>
</el-descriptions>
<div v-if="activeTab === 'info'" class="detail-panel">
<!-- 商品基础信息 -->
<div class="section">
<div class="section-title">基础信息</div>
<el-descriptions :column="3" border size="small" class="detail-descriptions">
<el-descriptions-item label="商品编码">{{ selectedRow.item_code || '—' }}</el-descriptions-item>
<el-descriptions-item label="商品名称">{{ selectedRow.item_name || '—' }}</el-descriptions-item>
<el-descriptions-item label="商家编码">{{ selectedRow.goods_code || '—' }}</el-descriptions-item>
<el-descriptions-item label="品牌">{{ selectedRow.brand_name || '—' }}</el-descriptions-item>
<el-descriptions-item label="库存单位">{{ selectedRow.stock_unit || '—' }}</el-descriptions-item>
<el-descriptions-item label="毛重">{{ selectedRow.gross_weight != null ? selectedRow.gross_weight + 'g' : '—' }}</el-descriptions-item>
<el-descriptions-item label="条码" :span="3">
<template v-if="selectedRow.barcodes && selectedRow.barcodes.length">
<el-tag
v-for="(bc, idx) in selectedRow.barcodes"
:key="idx"
size="small"
style="margin-right: 4px; margin-bottom: 2px"
>{{ bc }}</el-tag>
</template>
<span v-else>—</span>
</el-descriptions-item>
</el-descriptions>
</div>
<!-- 管理属性 -->
<div class="section">
<div class="section-title">管理属性</div>
<el-descriptions :column="3" border size="small" class="detail-descriptions">
<el-descriptions-item label="序列号管理">
<span :class="getStatusTextClass(selectedRow.is_sn_mgmt === 'Y' ? 'success' : 'info')">
{{ selectedRow.is_sn_mgmt === 'Y' ? '是' : '否' }}
</span>
</el-descriptions-item>
<el-descriptions-item label="效期管理">
<span :class="getStatusTextClass(selectedRow.is_shelf_life_mgmt === 'Y' ? 'success' : 'info')">
{{ selectedRow.is_shelf_life_mgmt === 'Y' ? '是' : '否' }}
</span>
</el-descriptions-item>
<el-descriptions-item label="批次管理">
<span :class="getStatusTextClass(selectedRow.is_batch_mgmt === 'Y' ? 'success' : 'info')">
{{ selectedRow.is_batch_mgmt === 'Y' ? '是' : '否' }}
</span>
</el-descriptions-item>
<el-descriptions-item label="打包要求" :span="3">{{ selectedRow.packing_requirements || '—' }}</el-descriptions-item>
</el-descriptions>
</div>
<!-- 时间信息 -->
<div class="section">
<div class="section-title">时间信息</div>
<el-descriptions :column="2" border size="small" class="detail-descriptions">
<el-descriptions-item label="创建时间">{{ selectedRow.create_at_display || '—' }}</el-descriptions-item>
<el-descriptions-item label="更新时间">{{ selectedRow.update_at_display || '—' }}</el-descriptions-item>
</el-descriptions>
</div>
</div>
<!-- 商品图片 -->
<div v-else-if="activeTab === 'images'" class="image-gallery" v-loading="imageLoading">
<template v-if="imageList.length">
<div v-else-if="activeTab === 'images'" class="image-panel" v-loading="imageLoading">
<div class="section-title">
商品图片
<span class="section-count">共 {{ imageList.length }} 张</span>
</div>
<div v-if="imageList.length" class="image-gallery">
<el-image
v-for="(img, idx) in imageList"
:key="idx"
:src="img.url"
:preview-src-list="imageList.map(i => i.url)"
:preview-src-list="imageUrls"
:initial-index="idx"
fit="cover"
preview-teleported
class="gallery-image"
/>
</template>
<el-empty v-else description="暂无商品图片" :image-size="60" />
>
<template #error>
<div class="image-error">加载失败</div>
</template>
</el-image>
</div>
<div v-else class="gallery-empty">
<el-empty description="暂无商品图片" :image-size="60" />
</div>
</div>
<!-- 外部商品绑定 -->
@ -712,6 +742,9 @@ function handleRowClick(row: any) {
const imageList = ref<{ url: string; name: string }[]>([])
const imageLoading = ref(false)
/** 预览大图地址(与 imageList 同序,避免模板内重复 map) */
const imageUrls = computed(() => imageList.value.map((img) => img.url).filter(Boolean))
async function loadImages(row: any) {
if (!row?.id) {
imageList.value = []
@ -721,10 +754,13 @@ async function loadImages(row: any) {
try {
const res: any = await getImages({ type: 'stock', id: row.id })
const raw = res?.data || res || []
imageList.value = (Array.isArray(raw) ? raw : []).map((img: any) => ({
url: img?.file?.file_url || img?.url || '',
name: img?.file?.file_name || img?.name || ''
}))
imageList.value = (Array.isArray(raw) ? raw : [])
.map((img: any) => ({
url: img?.file?.file_url || img?.url || '',
name: img?.file?.file_name || img?.name || ''
}))
// 过滤掉无地址的脏数据,避免画廊出现空白格子
.filter((img) => !!img.url)
} catch {
imageList.value = []
} finally {
@ -803,11 +839,52 @@ onMounted(() => {
<style scoped lang="scss">
@use "../../order/orderManagement/styles/order-sub.scss";
/* 详情区外壳:不留上/下间距(外部绑定、日志组件自带 padding;
基本信息、商品图片面板自带 padding),只保留左右 10px */
.order-sub-container .main-content .lower-level .detail-container {
padding: 10px;
padding: 0 10px;
overflow: auto;
}
/* 基本信息 / 商品图片面板:分区标题统一样式(对齐 express/waybill「运单明细」新样式) */
.detail-panel,
.image-panel {
padding: 8px 0;
.section-title {
font-size: 14px;
font-weight: 600;
color: #303133;
margin-bottom: 10px;
padding-left: 8px;
border-left: 3px solid #409eff;
line-height: 1.4;
.section-count {
margin-left: 6px;
font-size: 12px;
font-weight: 400;
color: #909399;
}
}
.section {
margin-bottom: 12px;
&:last-child {
margin-bottom: 0;
}
}
}
.detail-panel .detail-descriptions {
:deep(.el-descriptions__label) {
width: 120px;
background: #fafbfc;
font-weight: 500;
}
}
.empty-tip {
text-align: center;
font-size: 13px;
@ -829,20 +906,59 @@ onMounted(() => {
font-size: 12px;
}
.image-gallery {
/* 商品图片:等高卡片网格,列宽固定,多图自动换行且行列对齐 */
.image-panel {
height: 100%;
display: flex;
flex-wrap: wrap;
gap: 8px;
flex-direction: column;
box-sizing: border-box;
}
.image-gallery {
display: grid;
grid-template-columns: repeat(auto-fill, 104px);
gap: 10px;
justify-content: flex-start;
align-content: flex-start;
.gallery-image {
width: 100px;
height: 100px;
border-radius: 4px;
width: 104px;
height: 104px;
border-radius: 6px;
border: 1px solid #ebeef5;
background: #fafafa;
cursor: pointer;
overflow: hidden;
transition: border-color 0.2s, box-shadow 0.2s;
&:hover {
border-color: #409eff;
box-shadow: 0 2px 8px rgba(64, 158, 255, 0.2);
}
}
}
/* 空状态:撑满面板并水平垂直居中,不再贴在最左侧 */
.gallery-empty {
flex: 1;
width: 100%;
min-height: 160px;
display: flex;
align-items: center;
justify-content: center;
}
.image-error {
width: 100%;
height: 100%;
display: flex;
align-items: center;
justify-content: center;
font-size: 12px;
color: #909399;
background: #fafafa;
}
.erp-stock-wrapper,
.log-wrapper {
height: 100%;

View File

@ -1,40 +1,47 @@
<template>
<div class="erp-stock-container">
<el-button-group class="toolbar-btn-group">
<el-button
type="primary"
size="small"
icon="Refresh"
@click="fetchStockInfo"
title="刷新"
:loading="loading"
class="toolbar-btn"
>
刷新
</el-button>
<el-button
type="primary"
size="small"
icon="Plus"
@click="handleAddBind"
title="建议外部ERP修改商品编码重新推送,可以自动绑定"
class="toolbar-btn"
>
添加绑定
</el-button>
</el-button-group>
<el-table :data="tableData" border stripe style="width: 100%; height: 100%" height="100%">
<el-table-column prop="create_from" label="来源" width="150" />
<el-table-column prop="app_name" label="应用" width="120" />
<el-table-column prop="item_code" label="外部编码" />
<el-table-column prop="item_name" label="外部商品名称" />
<el-table-column label="操作" width="100">
<template #default="scope">
<el-button @click="unbindItem(scope.row)" type="primary" link size="small">解绑</el-button>
</template>
</el-table-column>
</el-table>
<div class="header-actions">
<div class="left-actions">
<el-button size="small" type="primary" :loading="loading" @click="fetchStockInfo">刷新</el-button>
<el-button
size="small"
type="primary"
plain
title="建议外部ERP修改商品编码重新推送,可以自动绑定"
@click="handleAddBind"
>
添加绑定
</el-button>
</div>
</div>
<div ref="tableHostRef" class="table-host">
<el-table ref="tableRef" :data="pagedTableData" border stripe size="small" style="width: 100%" :height="tableHeight">
<el-table-column prop="create_from" label="来源" width="150" />
<el-table-column prop="app_name" label="应用" width="120" />
<el-table-column prop="item_code" label="外部编码" />
<el-table-column prop="item_name" label="外部商品名称" />
<el-table-column label="操作" width="100">
<template #default="scope">
<el-button @click="unbindItem(scope.row)" type="primary" link size="small">解绑</el-button>
</template>
</el-table-column>
</el-table>
</div>
<div class="pagination-container">
<el-pagination
v-model:current-page="pagination.page"
v-model:page-size="pagination.pageSize"
:page-sizes="[10, 20, 50, 100]"
:total="pagination.total"
layout="total, sizes, prev, pager, next, jumper"
background
size="small"
@size-change="handlePageSizeChange"
@current-change="handlePageChange"
/>
</div>
<el-drawer
v-model="showStoreStock"
@ -54,8 +61,9 @@
</template>
<script setup lang="ts">
import { ref, watch, onMounted } from 'vue'
import { ref, reactive, computed, watch, onMounted, nextTick } from 'vue'
import { ElMessage } from 'element-plus'
import { useResizeObserver } from '@vueuse/core'
import { Refresh, Plus } from '@element-plus/icons-vue'
import * as stockApi from '@/api/stock/stock'
import StoreStock from './store_stock.vue'
@ -71,13 +79,66 @@ const tableData = ref<any[]>([])
const showStoreStock = ref(false)
const store_id = ref(0)
/* 表格高度:由容器实际高度驱动(Element Plus 不支持 height="100%") */
const tableHostRef = ref<HTMLElement | null>(null)
const tableRef = ref<any>(null)
const tableHeight = ref(280)
/* 分页器(接口一次性返回全部关联,所以用前端分页,交互与日志一致) */
const pagination = reactive({
page: 1,
pageSize: 20,
total: 0
})
/** 当前页数据 */
const pagedTableData = computed(() => {
const start = (pagination.page - 1) * pagination.pageSize
return tableData.value.slice(start, start + pagination.pageSize)
})
function handlePageChange(page: number) {
pagination.page = page
resetTableScroll()
}
function handlePageSizeChange(pageSize: number) {
pagination.pageSize = pageSize
pagination.page = 1
resetTableScroll()
}
/** 切页后把表格滚动位置归零 */
function resetTableScroll() {
nextTick(() => {
tableRef.value?.setScrollTop?.(0)
})
}
useResizeObserver(tableHostRef, (entries) => {
const h = entries[0]?.contentRect.height ?? 0
if (h >= 100) {
tableHeight.value = Math.floor(h)
}
})
watch(() => props.id, (newVal) => {
pagination.page = 1
if (newVal) {
fetchStockInfo()
} else {
tableData.value = []
pagination.total = 0
store_id.value = 0
}
requestAnimationFrame(() => {
const el = tableHostRef.value
if (el) {
const h = el.getBoundingClientRect().height
if (h >= 100) tableHeight.value = Math.floor(h)
}
})
})
onMounted(() => {
@ -114,8 +175,15 @@ async function fetchStockInfo() {
})
// console.log(response)
if (response.code == 200) {
tableData.value = response.data.rows
store_id.value = response.data.store_id
const rows: any[] = Array.isArray(response.data?.rows) ? response.data.rows : []
tableData.value = rows
store_id.value = response.data?.store_id ?? 0
pagination.total = rows.length
// 解绑/刷新后当前页可能已超出范围,回退到最后一页
const maxPage = Math.max(1, Math.ceil(rows.length / pagination.pageSize))
if (pagination.page > maxPage) {
pagination.page = maxPage
}
} else {
throw new Error('请求失败')
}
@ -138,20 +206,63 @@ function handleAddBind() {
</script>
<style scoped lang="scss">
/* 样式与 storage/receiving「商品明细」保持一致:
header-actions(按钮行,间距 6px 对齐 toolbar) + table-host(自适应剩余高度) */
.erp-stock-container {
width: 100%;
height: 100%;
padding: 10px;
padding: 6px 10px 8px;
overflow: hidden;
display: flex;
flex-direction: column;
background: #fff;
box-sizing: border-box;
}
.toolbar-btn-group {
margin-bottom: 5px;
.header-actions {
display: flex;
justify-content: space-between;
align-items: center;
margin-bottom: 6px;
flex-shrink: 0;
gap: 4px;
flex-wrap: wrap;
}
.el-table {
.left-actions {
display: flex;
align-items: center;
gap: 6px;
/* 清除 Element Plus 默认按钮左边距,统一由 gap 控制等间距 */
:deep(.el-button) {
margin-left: 0;
margin-right: 0;
}
}
.table-host {
flex: 1;
min-height: 120px;
min-width: 0;
overflow: hidden;
}
.pagination-container {
flex-shrink: 0;
display: flex;
justify-content: flex-end;
align-items: center;
margin-top: 6px;
/* 每页条数下拉框与 UpperTable 的分页器保持一致 */
:deep(.el-select--small) {
width: 80px;
}
:deep(.el-input__wrapper) {
padding: 0 4px;
}
}
:deep(.el-drawer__body) {

View File

@ -1,24 +1,19 @@
<template>
<div class="log-container">
<el-button-group class="toolbar-btn-group">
<el-button
type="primary"
size="small"
@click="fetchStockInfo"
title="刷新"
:loading="loading"
class="toolbar-btn"
>
刷新
</el-button>
</el-button-group>
<div class="header-actions">
<div class="left-actions">
<el-button size="small" type="primary" :loading="loading" @click="fetchStockInfo">刷新</el-button>
</div>
</div>
<div ref="tableHostRef" class="table-host">
<el-table
:data="tableData"
border
stripe
style="width: 100%; height: 100%"
height="100%"
size="small"
style="width: 100%"
:height="tableHeight"
v-loading="loading"
>
<el-table-column prop="created_at" label="时间" width="250" />
@ -49,6 +44,7 @@
</template>
</el-table-column>
</el-table>
</div>
<div class="pagination-container">
<el-pagination
@ -58,6 +54,7 @@
:total="pagination.total"
layout="total, sizes, prev, pager, next, jumper"
background
size="small"
@size-change="handlePageSizeChange"
@current-change="handlePageChange"
/>
@ -82,6 +79,7 @@
<script setup lang="ts">
import { ref, reactive, watch, onMounted } from 'vue'
import { ElMessage, ElMessageBox } from 'element-plus'
import { useResizeObserver } from '@vueuse/core'
import { Refresh } from '@element-plus/icons-vue'
import * as stockApi from '@/api/stock/stock'
import RequestData from '@/components/RequestData/index.vue'
@ -96,12 +94,23 @@ const showRequestData = ref(false)
const requestId = ref(0)
const requestType = ref('')
/* 表格高度:由容器实际高度驱动(Element Plus 不支持 height="100%") */
const tableHostRef = ref<HTMLElement | null>(null)
const tableHeight = ref(280)
const pagination = reactive({
page: 1,
pageSize: 20,
total: 0
})
useResizeObserver(tableHostRef, (entries) => {
const h = entries[0]?.contentRect.height ?? 0
if (h >= 100) {
tableHeight.value = Math.floor(h)
}
})
watch(() => props.id, (newVal) => {
if (newVal) {
fetchStockInfo()
@ -109,6 +118,14 @@ watch(() => props.id, (newVal) => {
tableData.value = []
pagination.total = 0
}
requestAnimationFrame(() => {
const el = tableHostRef.value
if (el) {
const h = el.getBoundingClientRect().height
if (h >= 100) tableHeight.value = Math.floor(h)
}
})
})
onMounted(() => {
@ -141,8 +158,24 @@ async function fetchStockInfo() {
const response: any = await stockApi.queryStockLogs(params)
if (response.code == 200) {
tableData.value = response.data.list
pagination.total = response.data.total || 0 // Assuming backend returns total
// 兼容 { data: { list, pagination } } 与 { list, pagination } 两种包装
const data = response?.data && typeof response.data === 'object' ? response.data : response
const list = Array.isArray(data?.list)
? data.list
: Array.isArray(data?.rows)
? data.rows
: []
tableData.value = list
// 总数兜底:pagination.total → total / total_count / count → 当前页条数
const rawTotal: any = data?.pagination?.total ?? data?.total ?? data?.total_count ?? data?.count
const total = Number(rawTotal)
pagination.total = Number.isFinite(total) ? total : list.length
const resPage = Number(data?.pagination?.page)
const resPageSize = Number(data?.pagination?.pageSize)
if (resPage > 0) pagination.page = resPage
if (resPageSize > 0) pagination.pageSize = resPageSize
} else {
throw new Error('请求失败')
}
@ -186,27 +219,63 @@ function backData(row: any) {
</script>
<style scoped lang="scss">
/* 样式与 storage/receiving「商品明细」保持一致:
header-actions(按钮行,间距 6px 对齐 toolbar) + table-host(自适应剩余高度) + 右对齐分页 */
.log-container {
width: 100%;
height: 100%;
padding: 10px;
padding: 6px 10px 8px;
overflow: hidden;
display: flex;
flex-direction: column;
background: #fff;
box-sizing: border-box;
}
.toolbar-btn-group {
margin-bottom: 5px;
.header-actions {
display: flex;
justify-content: space-between;
align-items: center;
margin-bottom: 6px;
flex-shrink: 0;
gap: 4px;
flex-wrap: wrap;
}
.el-table {
.left-actions {
display: flex;
align-items: center;
gap: 6px;
/* 清除 Element Plus 默认按钮左边距,统一由 gap 控制等间距 */
:deep(.el-button) {
margin-left: 0;
margin-right: 0;
}
}
.table-host {
flex: 1;
min-height: 120px;
min-width: 0;
overflow: hidden;
}
.pagination-container {
flex-shrink: 0;
display: flex;
justify-content: flex-end;
align-items: center;
margin-top: 10px;
margin-top: 6px;
/* 每页条数下拉框与 UpperTable 的分页器保持一致 */
:deep(.el-select--small) {
width: 80px;
}
:deep(.el-input__wrapper) {
padding: 0 4px;
}
}
:deep(.el-drawer__body) {

View File

@ -16,8 +16,8 @@
</el-button>
</div>
<div class="right-actions">
<el-tag v-if="canRemove" size="small" type="warning">未提交,可移除导入/PDA 记录</el-tag>
<el-tag v-else size="small" type="info">已提交或已作废,不可移除</el-tag>
<!-- <el-tag v-if="canRemove" size="small" type="warning">未提交,可移除导入/PDA 记录</el-tag>
<el-tag v-else size="small" type="info">已提交或已作废,不可移除</el-tag> -->
<span v-if="directLogList.length" class="summary-text">共 {{ directLogList.length }} 条记录</span>
</div>
</div>
@ -29,6 +29,7 @@
:show-selection="canRemove"
:multiple-selection="selectedRows"
:pagination="pagination"
:page-sizes="[10, 20, 50, 100]"
:loading="loading"
@selection-change="handleSelectionChange"
@page-size-change="handlePageSizeChange"
@ -293,17 +294,31 @@ defineExpose({
display: flex;
flex-direction: column;
height: 100%;
padding: 6px 10px 8px;
background: #fff;
box-sizing: border-box;
.header-actions {
display: flex;
justify-content: space-between;
align-items: center;
padding-bottom: 10px;
border-bottom: 1px solid #ebeef5;
margin-bottom: 10px;
margin-bottom: 6px;
flex-shrink: 0;
gap: 4px;
flex-wrap: wrap;
.left-actions {
display: flex;
align-items: center;
gap: 6px;
/* 清除 Element Plus 默认按钮左边距,统一由 gap 控制等间距 */
:deep(.el-button) {
margin-left: 0;
margin-right: 0;
}
}
.left-actions,
.right-actions {
display: flex;
align-items: center;
@ -318,7 +333,22 @@ defineExpose({
.table-content {
flex: 1;
min-height: 120px;
min-width: 0;
overflow: hidden;
/* 分页区与「操作日志」保持一致:去掉 UpperTable 默认的底部分隔线/内边距,
右对齐,仅保留 6px 上间距;左侧「已选 N 条 / 查询用时」文案一并去掉 */
:deep(.pagination-container) {
padding: 0;
border-top: none;
margin-top: 6px;
justify-content: flex-end;
}
:deep(.pagination-info) {
display: none;
}
}
.empty-tip {

View File

@ -1,5 +1,8 @@
<template>
<div class="entry-binding-relations">
<!-- 分区标题:置于刷新按钮上方 -->
<!-- <div class="section-title">绑定的收货单</div> -->
<div class="header-actions">
<div class="left-actions">
<el-button size="small" type="primary" :loading="loading" @click="loadBindingData">刷新</el-button>
@ -10,42 +13,54 @@
</div>
</div>
<div v-loading="loading" class="binding-content">
<section class="binding-section">
<div class="section-title">绑定的收货单</div>
<el-table
:data="receivingBindings"
border
stripe
size="small"
row-key="rowKey"
empty-text="暂无绑定的收货单"
max-height="220"
>
<el-table-column
v-for="col in entryReceivingBindingColumns"
:key="col.prop"
:prop="col.prop"
:label="col.label"
:width="col.width"
:min-width="col.minWidth"
show-overflow-tooltip
/>
<el-table-column label="操作" width="90" fixed="right" align="center">
<template #default="{ row }">
<el-button
link
type="primary"
size="small"
:loading="compareLoading && activeCompareReceivingId === row.receiving_id"
@click="loadComparePreview(row.receiving_id)"
>
对照
</el-button>
</template>
</el-table-column>
</el-table>
</section>
<div ref="tableHostRef" v-loading="loading" class="table-host">
<el-table
:data="pagedReceivingBindings"
border
stripe
style="width: 100%"
row-key="rowKey"
empty-text="暂无绑定的收货单"
:height="tableHeight"
>
<el-table-column
v-for="col in entryReceivingBindingColumns"
:key="col.prop"
:prop="col.prop"
:label="col.label"
:width="col.width"
:min-width="col.minWidth"
show-overflow-tooltip
/>
<el-table-column label="操作" width="90" fixed="right" align="center">
<template #default="{ row }">
<el-button
link
type="primary"
size="small"
:loading="compareLoading && activeCompareReceivingId === row.receiving_id"
@click="loadComparePreview(row.receiving_id)"
>
对照
</el-button>
</template>
</el-table-column>
</el-table>
</div>
<div class="pagination-container">
<el-pagination
v-model:current-page="bindingPagination.currentPage"
v-model:page-size="bindingPagination.pageSize"
:page-sizes="[10, 20, 50, 100]"
:total="bindingPagination.total"
layout="total, sizes, prev, pager, next, jumper"
background
size="small"
@size-change="handleBindingPageSizeChange"
@current-change="handleBindingPageChange"
/>
</div>
<!-- <section class="binding-section">
<div class="section-title">明细绑定关系</div>
@ -71,59 +86,59 @@
</el-table>
</section> -->
<section v-if="comparePreview" v-loading="compareLoading" class="binding-section">
<div class="section-title">
对照预览
<span v-if="comparePreviewReceivingNumber" class="section-subtitle">
{{ comparePreviewReceivingNumber }}
</span>
</div>
<section v-if="comparePreview" v-loading="compareLoading" class="binding-section">
<div class="section-title">
对照预览
<span v-if="comparePreviewReceivingNumber" class="section-subtitle">
{{ comparePreviewReceivingNumber }}
</span>
</div>
<div v-if="compareSummaryItems.length" class="summary-grid">
<div
v-for="item in compareSummaryItems"
:key="item.key"
class="summary-card"
:class="`summary-card--${item.cardType}`"
>
<div class="summary-value">{{ item.value }}</div>
<div class="summary-label">{{ item.label }}</div>
</div>
</div>
<el-table
:data="compareRows"
border
stripe
size="small"
row-key="rowKey"
empty-text="暂无对照数据"
max-height="260"
<div v-if="compareSummaryItems.length" class="summary-grid">
<div
v-for="item in compareSummaryItems"
:key="item.key"
class="summary-card"
:class="`summary-card--${item.cardType}`"
>
<el-table-column
v-for="col in entryBindingCompareColumns"
:key="col.prop"
:prop="col.prop"
:label="col.label"
:width="col.width"
:min-width="col.minWidth"
:align="col.align"
show-overflow-tooltip
>
<template v-if="col.prop === 'match_status_label'" #default="{ row }">
<span :class="getStatusTextClass(getReceivingCompareStatusTagType(row.match_status))">
{{ row.match_status_label }}
</span>
</template>
</el-table-column>
</el-table>
</section>
</div>
<div class="summary-value">{{ item.value }}</div>
<div class="summary-label">{{ item.label }}</div>
</div>
</div>
<el-table
:data="compareRows"
border
stripe
style="width: 100%"
row-key="rowKey"
empty-text="暂无对照数据"
max-height="260"
>
<el-table-column
v-for="col in entryBindingCompareColumns"
:key="col.prop"
:prop="col.prop"
:label="col.label"
:width="col.width"
:min-width="col.minWidth"
:align="col.align"
show-overflow-tooltip
>
<template v-if="col.prop === 'match_status_label'" #default="{ row }">
<span :class="getStatusTextClass(getReceivingCompareStatusTagType(row.match_status))">
{{ row.match_status_label }}
</span>
</template>
</el-table-column>
</el-table>
</section>
</div>
</template>
<script setup lang="ts">
import { computed, ref, watch, onActivated } from 'vue'
import { computed, reactive, ref, watch, onActivated, onMounted } from 'vue'
import { useResizeObserver } from '@vueuse/core'
import { getStatusTextClass } from '@/views/order/orderManagement/config/order-common-config'
import { ElMessage } from 'element-plus'
import {
@ -195,6 +210,45 @@ const itemBindingRows = ref<ItemBindingRow[]>([])
const comparePreview = ref<ReceivingCompareResponse | null>(null)
const activeCompareReceivingId = ref<number | null>(null)
/** 绑定的收货单:接口一次性返回全部绑定关系,故用前端分页 */
const bindingPagination = reactive({ currentPage: 1, pageSize: 20, total: 0 })
/* 表格高度:由容器实际高度驱动(Element Plus 不支持 height="100%") */
const tableHostRef = ref<HTMLElement | null>(null)
const tableHeight = ref(220)
useResizeObserver(tableHostRef, (entries) => {
const h = entries[0]?.contentRect.height ?? 0
if (h >= 100) {
tableHeight.value = Math.floor(h)
}
})
/** 切行 / 切 tab 后用 rAF 兜底测高 */
function syncTableHeight() {
requestAnimationFrame(() => {
const el = tableHostRef.value
if (el) {
const h = el.getBoundingClientRect().height
if (h >= 100) tableHeight.value = Math.floor(h)
}
})
}
const pagedReceivingBindings = computed(() => {
const start = (bindingPagination.currentPage - 1) * bindingPagination.pageSize
return receivingBindings.value.slice(start, start + bindingPagination.pageSize)
})
function handleBindingPageChange(page: number) {
bindingPagination.currentPage = page
}
function handleBindingPageSizeChange(size: number) {
bindingPagination.pageSize = size
bindingPagination.currentPage = 1
}
const comparePreviewReceivingNumber = computed(
() => comparePreview.value?.comparisons?.[0]?.receiving_number ?? ''
)
@ -221,20 +275,28 @@ watch(
() => {
comparePreview.value = null
activeCompareReceivingId.value = null
bindingPagination.currentPage = 1
if (props.id) {
void loadBindingData()
} else {
receivingBindings.value = []
itemBindingRows.value = []
bindingPagination.total = 0
}
syncTableHeight()
},
{ immediate: true }
)
onMounted(() => {
syncTableHeight()
})
onActivated(() => {
if (props.id) {
void loadBindingData()
}
syncTableHeight()
})
function isApiSuccess(res: { code?: number; flag?: string } | null | undefined): boolean {
@ -333,6 +395,7 @@ async function loadBindingData() {
if (!Number.isFinite(entryOrderId) || entryOrderId <= 0) {
receivingBindings.value = []
itemBindingRows.value = []
bindingPagination.total = 0
return
}
@ -365,11 +428,18 @@ async function loadBindingData() {
receivingBindings.value = (bindings as EntryOrderReceivingBinding[]).map(mapReceivingBindingRow)
itemBindingRows.value = buildItemBindingRows(items as EntryDetailItem[])
bindingPagination.total = receivingBindings.value.length
// 数据刷新后当前页可能超出范围,回退到最后一页
const maxPage = Math.max(1, Math.ceil(bindingPagination.total / bindingPagination.pageSize))
if (bindingPagination.currentPage > maxPage) {
bindingPagination.currentPage = maxPage
}
} catch (error) {
console.error('获取绑定关系失败:', error)
ElMessage.error('获取绑定关系失败')
receivingBindings.value = []
itemBindingRows.value = []
bindingPagination.total = 0
} finally {
loading.value = false
}
@ -414,26 +484,35 @@ defineExpose({
display: flex;
flex-direction: column;
height: 100%;
padding: 6px 10px 8px;
background: #fff;
box-sizing: border-box;
.header-actions {
display: flex;
justify-content: space-between;
align-items: center;
padding-bottom: 10px;
border-bottom: 1px solid #ebeef5;
margin-bottom: 10px;
margin-bottom: 6px;
flex-shrink: 0;
gap: 4px;
flex-wrap: wrap;
.left-actions {
display: flex;
align-items: center;
gap: 6px;
/* 清除 Element Plus 默认按钮左边距,统一由 gap 控制等间距 */
:deep(.el-button) {
margin-left: 0;
margin-right: 0;
}
}
.right-actions {
display: flex;
align-items: center;
gap: 12px;
gap: 8px;
}
.summary-text {
@ -442,29 +521,48 @@ defineExpose({
}
}
.binding-content {
/* 表格容器:撑满剩余高度(与操作日志一致) */
.table-host {
flex: 1;
min-height: 0;
overflow: auto;
display: flex;
flex-direction: column;
gap: 14px;
-ms-overflow-style: none;
scrollbar-width: none;
min-height: 120px;
min-width: 0;
overflow: hidden;
}
&::-webkit-scrollbar {
display: none;
/* 分页区:与其它详情面板一致(右对齐、上间距 6px) */
.pagination-container {
margin-top: 6px;
display: flex;
justify-content: flex-end;
align-items: center;
flex-shrink: 0;
/* 每页条数下拉框与 UpperTable(入库明细/入库记录)的分页器保持一致 */
:deep(.el-select--small) {
width: 80px;
}
:deep(.el-input__wrapper) {
padding: 0 4px;
}
}
/* 对照预览:点「对照」后出现,固定在底部,表格自身滚动 */
.binding-section {
.section-title {
margin-bottom: 8px;
font-size: 13px;
font-weight: 600;
color: #303133;
line-height: 1.4;
}
flex-shrink: 0;
margin-top: 12px;
}
/* 分区标题(面板顶部与各 binding-section 通用) */
.section-title {
flex-shrink: 0;
margin-bottom: 10px;
padding-left: 8px;
border-left: 3px solid #409eff;
font-size: 14px;
font-weight: 600;
color: #303133;
line-height: 1.4;
.section-subtitle {
margin-left: 8px;

View File

@ -37,6 +37,7 @@
:columns="detailColumns"
:show-selection="true"
:pagination="pagination"
:page-sizes="[10, 20, 50, 100]"
:loading="loading"
@selection-change="handleSelectionChange"
@page-size-change="handlePageSizeChange"
@ -398,20 +399,29 @@ onMounted(() => {
display: flex;
flex-direction: column;
height: 100%;
padding: 6px 10px 8px;
background: #fff;
box-sizing: border-box;
.header-actions {
display: flex;
justify-content: space-between;
align-items: center;
padding-bottom: 10px;
border-bottom: 1px solid #ebeef5;
margin-bottom: 10px;
margin-bottom: 6px;
flex-shrink: 0;
gap: 4px;
flex-wrap: wrap;
.left-actions {
display: flex;
align-items: center;
gap: 6px;
/* 清除 Element Plus 默认按钮左边距,统一由 gap 控制等间距 */
:deep(.el-button) {
margin-left: 0;
margin-right: 0;
}
}
.right-actions {
@ -428,8 +438,22 @@ onMounted(() => {
.table-content {
flex: 1;
min-height: 200px;
min-height: 120px;
min-width: 0;
overflow: hidden;
/* 分页区与「操作日志」保持一致:去掉 UpperTable 默认的底部分隔线/内边距,
右对齐,仅保留 6px 上间距;左侧「已选 N 条 / 查询用时」文案一并去掉 */
:deep(.pagination-container) {
padding: 0;
border-top: none;
margin-top: 6px;
justify-content: flex-end;
}
:deep(.pagination-info) {
display: none;
}
}
}
</style>

View File

@ -1,18 +1,18 @@
<template>
<div class="log-container">
<el-button-group class="toolbar-btn-group">
<el-button
type="primary"
size="small"
title="刷新"
:loading="loading"
class="toolbar-btn"
:disabled="!entryId"
@click="handleRefresh"
>
刷新
</el-button>
</el-button-group>
<div class="header-actions">
<div class="left-actions">
<el-button
size="small"
type="primary"
:loading="loading"
:disabled="!entryId"
@click="handleRefresh"
>
刷新
</el-button>
</div>
</div>
<div ref="tableHostRef" class="table-host">
<el-table
@ -245,15 +245,33 @@ function viewData(row: any) {
.log-container {
height: 100%;
width: 100%;
padding: 6px 10px;
padding: 6px 10px 8px;
overflow: hidden;
display: flex;
flex-direction: column;
background: #fff;
box-sizing: border-box;
.toolbar-btn-group {
.header-actions {
display: flex;
justify-content: space-between;
align-items: center;
margin-bottom: 6px;
flex-shrink: 0;
gap: 4px;
flex-wrap: wrap;
.left-actions {
display: flex;
align-items: center;
gap: 6px;
/* 清除 Element Plus 默认按钮左边距,统一由 gap 控制等间距 */
:deep(.el-button) {
margin-left: 0;
margin-right: 0;
}
}
}
.table-host {
@ -264,12 +282,20 @@ function viewData(row: any) {
}
.pagination-container {
margin-top: 8px;
padding-top: 4px;
margin-top: 6px;
display: flex;
justify-content: flex-end;
align-items: center;
flex-shrink: 0;
/* 每页条数下拉框与 UpperTable(入库明细/入库记录)的分页器保持一致 */
:deep(.el-select--small) {
width: 80px;
}
:deep(.el-input__wrapper) {
padding: 0 4px;
}
}
.cell-muted {

View File

@ -1290,8 +1290,10 @@ function handleImport() {
<style scoped lang="scss">
@use "../../order/orderManagement/styles/order-sub.scss";
/* 详情区外壳与 stock/external_stock 保持一致:不留上/下间距(各详情组件自带
padding: 6px 10px 8px),只保留左右 10px,避免与组件内边距叠加 */
.order-sub-container .main-content .lower-level .detail-container {
padding: 10px;
padding: 0 10px;
overflow: auto;
}

View File

@ -693,8 +693,10 @@ async function handleExportSelected() {
<style scoped lang="scss">
@use "@/views/order/orderManagement/styles/order-sub.scss";
/* 详情区外壳与 stock/external_stock 保持一致:不留上/下间距(各详情组件自带
padding: 6px 10px 8px),只保留左右 10px,避免与组件内边距叠加 */
.order-sub-container .main-content .lower-level .detail-container {
padding: 10px;
padding: 0 10px;
overflow: auto;
}

View File

@ -43,6 +43,21 @@
</el-button>
</span>
</el-tooltip>
<el-tooltip
content="请先在下方明细列表勾选一条库存记录(含库存记录 ID)"
:disabled="canEditExpiry"
>
<span class="transfer-btn-wrap">
<el-button
size="small"
type="warning"
:disabled="!canEditExpiry"
@click="openExpiryDialog"
>
维护生产/到期日期
</el-button>
</span>
</el-tooltip>
</el-button-group>
<el-radio-group
v-if="!groupByBatch"
@ -87,6 +102,92 @@
</el-button>
</template>
</el-dialog>
<el-dialog
v-model="expiryDialogVisible"
title="维护生产日期 / 到期日期"
width="560px"
align-center
@opened="handleExpiryDialogOpened"
@closed="resetExpiryForm"
>
<el-descriptions class="expiry-context" :column="2" size="small" border>
<el-descriptions-item label="库存记录ID">{{ expiryRow?.storage_id ?? '--' }}</el-descriptions-item>
<el-descriptions-item label="批次号">{{ expiryRow?.batch_no || '--' }}</el-descriptions-item>
<el-descriptions-item label="商品">{{ expiryItemLabel }}</el-descriptions-item>
<el-descriptions-item label="库位">{{ expiryRow?.space_code || '--' }}</el-descriptions-item>
</el-descriptions>
<p class="expiry-hint">
输入框已回显库内当前日期:不改动=保持原值(不下发);改选日期=下发新日期;点「清空」清空输入框=下发 null 置空。两个日期至少改一项,且生产日期不得晚于到期日期。
</p>
<el-form label-width="80px" class="expiry-form">
<el-form-item label="生产日期">
<div class="expiry-field">
<el-date-picker
ref="productionPickerRef"
v-model="expiryForm.productionDate"
type="date"
value-format="YYYY-MM-DD"
format="YYYY-MM-DD"
placeholder="请选择生产日期"
class="expiry-date-picker"
clearable
/>
<el-button
type="primary"
link
class="expiry-clear-btn"
:disabled="!expiryForm.productionDate"
@click="expiryForm.productionDate = ''"
>
清空
</el-button>
</div>
</el-form-item>
<el-form-item label="到期日期">
<div class="expiry-field">
<el-date-picker
ref="expiryPickerRef"
v-model="expiryForm.expiryDate"
type="date"
value-format="YYYY-MM-DD"
format="YYYY-MM-DD"
placeholder="请选择到期日期"
class="expiry-date-picker"
clearable
/>
<el-button
type="primary"
link
class="expiry-clear-btn"
:disabled="!expiryForm.expiryDate"
@click="expiryForm.expiryDate = ''"
>
清空
</el-button>
</div>
</el-form-item>
</el-form>
<!-- <div class="expiry-preview">
<span class="expiry-preview-label">提交内容</span>
<span class="expiry-preview-text">{{ expiryPayloadPreview }}</span>
</div> -->
<template #footer>
<el-button @click="expiryDialogVisible = false">取消</el-button>
<el-button
type="primary"
:loading="expiryLoading"
:disabled="!hasExpiryChange"
@click="confirmExpiry"
>
确认维护
</el-button>
</template>
</el-dialog>
<div ref="tableWrapRef" class="detail-table-wrap">
<el-table
ref="detailTableRef"
@ -107,7 +208,21 @@
:label="col.label"
:width="col.width"
show-overflow-tooltip
/>
>
<!-- 生产日期 / 到期日期:单元格可直接点击打开维护弹窗并展开对应日历 -->
<template v-if="isExpiryDateColumn(col.prop)" #default="{ row }">
<el-link
v-if="getRowStorageId(row)"
type="primary"
:underline="false"
:title="`点击快捷维护${col.label}`"
@click.stop="openExpiryDialog(row, col.prop === 'production_date' ? 'production' : 'expiry')"
>
{{ row[col.prop] || '--' }}
</el-link>
<span v-else>{{ row[col.prop] || '--' }}</span>
</template>
</el-table-column>
</el-table>
</div>
</div>
@ -115,8 +230,9 @@
</template>
<script setup lang="ts">
import { computed, nextTick, onBeforeUnmount, onMounted, ref, watch } from 'vue'
import { computed, nextTick, onBeforeUnmount, onMounted, reactive, ref, watch } from 'vue'
import * as inventoryApi from '@/api/storage.inventory/inventory'
import type { InventoryUpdateExpiryParams } from '@/api/storage.inventory/inventory'
import * as warehouseApi from '@/api/warehouse/warehouse'
import * as indexApi from '@/api/index/index'
import { ElMessage } from 'element-plus'
@ -446,6 +562,196 @@ async function confirmTransfer() {
}
}
/* ───────────────── 生产日期 / 到期日期维护(storage.inventory.updateExpiry) ───────────────── */
const expiryDialogVisible = ref(false)
const expiryLoading = ref(false)
const expiryRow = ref<any>(null)
/** 弹窗打开后需自动聚焦并展开日历的字段(由「生产日期 / 到期日期」单元格快捷入口指定) */
const expiryFocusField = ref<'production' | 'expiry' | null>(null)
const productionPickerRef = ref<any>(null)
const expiryPickerRef = ref<any>(null)
const expiryForm = reactive({
/** 输入框默认回显库内日期;与库内一致=不修改,清空输入框=下发 null 置空 */
productionDate: '',
expiryDate: ''
})
/**
* 由输入框内容推导单个字段的下发内容(UI 不再有额外开关,三态由「与库内值比较」自动得出):
* - undefined:与库内一致 —— 不下发,保持原值
* - null:输入框为空且库内有值 —— 清空该字段
* - string:下发该日期
*/
function resolveExpiryFieldPayload(value: string, current: unknown): string | null | undefined {
const picked = toComparableDate(value)
const currentNorm = toComparableDate(current)
if (picked === currentNorm) return undefined
return picked || null
}
/** 是否有需要下发的内容(至少一个字段被修改或清空),否则无从提交 */
const hasExpiryChange = computed(
() =>
resolveExpiryFieldPayload(expiryForm.productionDate, expiryRow.value?.production_date) !== undefined ||
resolveExpiryFieldPayload(expiryForm.expiryDate, expiryRow.value?.expiry_date) !== undefined
)
/** 行上的库存记录 ID(无则返回 null,用于判断该行是否可维护日期) */
function getRowStorageId(row: any): number | null {
const id = Number(row?.storage_id)
return Number.isFinite(id) && id > 0 ? id : null
}
/** 可点击快捷维护的日期列(与明细表列配置中的 prop 对应) */
const EXPIRY_DATE_COLUMN_PROPS = ['production_date', 'expiry_date']
function isExpiryDateColumn(prop: string): boolean {
return EXPIRY_DATE_COLUMN_PROPS.includes(prop)
}
/** 是否可维护日期:需要有一条含库存记录 ID 的库存明细行 */
const canEditExpiry = computed(() => getRowStorageId(activeRow.value) !== null)
const expiryItemLabel = computed(() => {
const row = expiryRow.value || {}
const code = String(row.item_code || '').trim()
const name = String(row.item_name || '').trim()
if (code && name) return `${code} ${name}`
return code || name || '--'
})
/** 日期展示:空值统一为「(空)」 */
function formatExpiryValue(value: unknown): string {
const text = value === null || value === undefined ? '' : String(value).trim()
return text || '(空)'
}
/** 单个字段的提交描述,与接口「未传=保持原值 / null 或空串=清空」语义一一对应 */
function describeExpiryField(value: string, current: unknown): string {
const next = resolveExpiryFieldPayload(value, current)
if (next === undefined) return '不下发,保持库内原值'
if (next === null) return 'null,清空该字段'
return next
}
/** 提交内容预览(让用户明确本次请求实际下发了哪些字段) */
const expiryPayloadPreview = computed(
() =>
`production_date:${describeExpiryField(expiryForm.productionDate, expiryRow.value?.production_date)};` +
`expiry_date:${describeExpiryField(expiryForm.expiryDate, expiryRow.value?.expiry_date)}`
)
/** 归一化为 YYYY-MM-DD 以便比较先后(兼容 YYYY/MM/DD、带时间与 ISO 串) */
function toComparableDate(value: unknown): string {
const text = String(value ?? '').trim()
if (!text) return ''
const matched = text.match(/^(\d{4})[-/](\d{1,2})[-/](\d{1,2})/)
if (!matched) return ''
return `${matched[1]}-${String(matched[2]).padStart(2, '0')}-${String(matched[3]).padStart(2, '0')}`
}
/** 变更前后文案:仅输出实际发生变化的字段 */
function buildExpiryChangeText(data: any): string {
const row = expiryRow.value || {}
const items: Array<[string, unknown, unknown]> = [
['生产日期', data?.before_production_date ?? row.production_date, data?.production_date],
['到期日期', data?.before_expiry_date ?? row.expiry_date, data?.expiry_date]
]
return items
.filter(([, before, after]) => formatExpiryValue(before) !== formatExpiryValue(after))
.map(([label, before, after]) => `${label}:${formatExpiryValue(before)} → ${formatExpiryValue(after)}`)
.join(';')
}
/**
* 打开日期维护弹窗(两个入口共用):
* 1. 工具栏「维护生产/到期日期」按钮:不传参,取当前勾选行;
* 2. 明细表「生产日期 / 到期日期」单元格:传入该行与目标字段,弹窗打开后自动展开对应日历
*/
function openExpiryDialog(row?: any, target?: 'production' | 'expiry') {
const targetRow = normalizeRow(row) || normalizeRow(activeRow.value) || {}
if (!getRowStorageId(targetRow)) {
ElMessage.warning(
row ? '该行缺少库存记录 ID,无法维护日期' : '请先在下方明细列表勾选一条库存记录'
)
return
}
expiryRow.value = targetRow
// 输入框回显库内当前日期(归一化为 YYYY-MM-DD,兼容接口返回的 ISO / 带时间格式)
expiryForm.productionDate = toComparableDate(targetRow.production_date)
expiryForm.expiryDate = toComparableDate(targetRow.expiry_date)
expiryFocusField.value = target || null
expiryDialogVisible.value = true
}
/** 弹窗打开动画结束后,聚焦并展开快捷入口指定的日期选择器 */
async function handleExpiryDialogOpened() {
const target = expiryFocusField.value
if (!target) return
await nextTick()
const picker = target === 'production' ? productionPickerRef.value : expiryPickerRef.value
picker?.focus?.()
picker?.handleOpen?.()
}
function resetExpiryForm() {
expiryRow.value = null
expiryFocusField.value = null
expiryForm.productionDate = ''
expiryForm.expiryDate = ''
}
async function confirmExpiry() {
const row = expiryRow.value || {}
const storageId = Number(row.storage_id)
if (!Number.isInteger(storageId) || storageId <= 0) {
ElMessage.warning('缺少库存记录 ID,请重新选择一条库存明细行')
return
}
const production = resolveExpiryFieldPayload(expiryForm.productionDate, row.production_date)
const expiry = resolveExpiryFieldPayload(expiryForm.expiryDate, row.expiry_date)
if (production === undefined && expiry === undefined) {
ElMessage.warning('生产日期与到期日期均未改动,请修改后再提交')
return
}
const mergedProduction = toComparableDate(expiryForm.productionDate)
const mergedExpiry = toComparableDate(expiryForm.expiryDate)
if (mergedProduction && mergedExpiry && mergedProduction > mergedExpiry) {
ElMessage.warning('生产日期不能晚于到期日期,请调整后重试')
return
}
const payload: InventoryUpdateExpiryParams = { storage_id: storageId }
if (production !== undefined) payload.production_date = production
if (expiry !== undefined) payload.expiry_date = expiry
expiryLoading.value = true
try {
const res: any = await inventoryApi.updateInventoryExpiry(payload)
if (!(res && (res.code === 200 || res.code === 1 || res.flag === 'success'))) {
ElMessage.error(res?.message || '维护生产日期/到期日期失败')
return
}
const data = res.data || {}
if (data.changed === false) {
ElMessage.info(res.message || '生产日期与到期日期均无变化,未做修改')
} else {
const changeText = buildExpiryChangeText(data)
ElMessage.success(changeText ? `维护成功:${changeText}` : res.message || '维护成功')
}
expiryDialogVisible.value = false
await loadData()
emit('refresh')
} catch (e: any) {
console.error('维护生产日期/到期日期失败', e)
ElMessage.error(e?.message || '维护生产日期/到期日期失败')
} finally {
expiryLoading.value = false
}
}
/** 按库位汇总行归一化(无批次字段,含库位/数量/批次数/入库时间) */
function normalizeSpaceRow(item: any) {
const row = normalizeRow(item)
@ -582,5 +888,55 @@ watch(targetSpace, (val) => {
.target-space-error {
color: #f56c6c;
}
.expiry-context {
margin-bottom: 12px;
}
.expiry-hint {
margin: 0 0 12px;
font-size: 12px;
color: #909399;
line-height: 1.5;
}
.expiry-form {
.expiry-field {
display: flex;
align-items: center;
gap: 12px;
flex-wrap: wrap;
width: 100%;
}
.expiry-date-picker {
flex: 1;
min-width: 0;
}
.expiry-clear-btn {
flex-shrink: 0;
}
}
.expiry-preview {
display: flex;
gap: 8px;
padding: 8px 10px;
border-radius: 4px;
background: #f5f7fa;
font-size: 12px;
color: #606266;
line-height: 1.6;
.expiry-preview-label {
flex-shrink: 0;
color: #909399;
}
.expiry-preview-text {
word-break: break-all;
}
}
}
</style>

View File

@ -117,35 +117,67 @@
</el-tabs>
</div>
<div class="detail-container">
<div v-if="activeTab === 'detail'" class="detail-page">
<el-descriptions :column="2" border size="small">
<el-descriptions-item label="流水ID">{{ selectedRowData.id }}</el-descriptions-item>
<el-descriptions-item label="流水时间">{{ formatDateTime(selectedRowData.created_at) }}</el-descriptions-item>
<el-descriptions-item label="流水类型">
<span :class="getStatusTextClass(getTransactionTypeTag(selectedRowData.transaction_type))">
{{ getTransactionTypeLabel(selectedRowData.transaction_type) }}
</span>
</el-descriptions-item>
<el-descriptions-item label="操作人">{{ selectedRowData.operator_name || '—' }}</el-descriptions-item>
<el-descriptions-item label="商品ID">{{ selectedRowData.stock_id ?? '—' }}</el-descriptions-item>
<el-descriptions-item label="仓库ID">{{ selectedRowData.warehouse_id ?? '—' }}</el-descriptions-item>
<el-descriptions-item label="批次号">{{ selectedRowData.batch_no || '—' }}</el-descriptions-item>
<el-descriptions-item label="变动数量">
<span :class="getQuantityClass(selectedRowData)">{{ formatQuantityDisplay(selectedRowData) }}</span>
</el-descriptions-item>
<el-descriptions-item label="可用库存">
{{ selectedRowData.before_quantity ?? '—' }} → {{ selectedRowData.after_quantity ?? '—' }}
</el-descriptions-item>
<el-descriptions-item label="锁定库存">
{{ selectedRowData.before_locked_quantity ?? '—' }} → {{ selectedRowData.after_locked_quantity ?? '—' }}
</el-descriptions-item>
<el-descriptions-item label="订单类型">{{ getOrderTypeLabel(selectedRowData.order_type) }}</el-descriptions-item>
<el-descriptions-item label="订单号">{{ selectedRowData.order_no || '—' }}</el-descriptions-item>
<el-descriptions-item label="订单ID">{{ selectedRowData.order_id || '—' }}</el-descriptions-item>
<el-descriptions-item label="收货单ID">{{ selectedRowData.receiving_id || '—' }}</el-descriptions-item>
<el-descriptions-item label="入库单ID">{{ selectedRowData.entry_order_id || '—' }}</el-descriptions-item>
<el-descriptions-item label="备注" :span="2">{{ selectedRowData.remark || '—' }}</el-descriptions-item>
</el-descriptions>
<div v-if="activeTab === 'detail'" class="detail-page detail-panel">
<!-- 流水信息 -->
<div class="section">
<div class="section-title">流水信息</div>
<el-descriptions :column="4" border size="small" class="detail-descriptions">
<el-descriptions-item label="流水ID">{{ selectedRowData.id ?? '—' }}</el-descriptions-item>
<el-descriptions-item label="流水时间">{{ formatDateTime(selectedRowData.created_at) }}</el-descriptions-item>
<el-descriptions-item label="流水类型">
<span :class="getStatusTextClass(getTransactionTypeTag(selectedRowData.transaction_type))">
{{ getTransactionTypeLabel(selectedRowData.transaction_type) }}
</span>
</el-descriptions-item>
<el-descriptions-item label="操作人">{{ selectedRowData.operator_name || '—' }}</el-descriptions-item>
</el-descriptions>
</div>
<!-- 商品与仓库 -->
<div class="section">
<div class="section-title">商品与仓库</div>
<el-descriptions :column="3" border size="small" class="detail-descriptions">
<el-descriptions-item label="商品ID">{{ selectedRowData.stock_id ?? '—' }}</el-descriptions-item>
<el-descriptions-item label="仓库ID">{{ selectedRowData.warehouse_id ?? '—' }}</el-descriptions-item>
<el-descriptions-item label="批次号">{{ selectedRowData.batch_no || '—' }}</el-descriptions-item>
</el-descriptions>
</div>
<!-- 库存变动 -->
<div class="section">
<div class="section-title">库存变动</div>
<el-descriptions :column="3" border size="small" class="detail-descriptions">
<el-descriptions-item label="变动数量">
<span :class="getQuantityClass(selectedRowData)">{{ formatQuantityDisplay(selectedRowData) }}</span>
</el-descriptions-item>
<el-descriptions-item label="可用库存">
{{ selectedRowData.before_quantity ?? '—' }} → {{ selectedRowData.after_quantity ?? '—' }}
</el-descriptions-item>
<el-descriptions-item label="锁定库存">
{{ selectedRowData.before_locked_quantity ?? '—' }} → {{ selectedRowData.after_locked_quantity ?? '—' }}
</el-descriptions-item>
</el-descriptions>
</div>
<!-- 关联单据 -->
<div class="section">
<div class="section-title">关联单据</div>
<el-descriptions :column="3" border size="small" class="detail-descriptions">
<el-descriptions-item label="订单类型">{{ getOrderTypeLabel(selectedRowData.order_type) }}</el-descriptions-item>
<el-descriptions-item label="订单号">{{ selectedRowData.order_no || '—' }}</el-descriptions-item>
<el-descriptions-item label="订单ID">{{ selectedRowData.order_id || '—' }}</el-descriptions-item>
<el-descriptions-item label="收货单ID">{{ selectedRowData.receiving_id || '—' }}</el-descriptions-item>
<el-descriptions-item label="入库单ID" :span="2">{{ selectedRowData.entry_order_id || '—' }}</el-descriptions-item>
</el-descriptions>
</div>
<!-- 备注 -->
<div class="section">
<div class="section-title">备注</div>
<el-descriptions :column="1" border size="small" class="detail-descriptions">
<el-descriptions-item label="备注">{{ selectedRowData.remark || '—' }}</el-descriptions-item>
</el-descriptions>
</div>
</div>
</div>
</div>
@ -817,17 +849,43 @@ onMounted(() => {
min-height: 0;
display: flex;
flex-direction: column;
padding: 10px;
/* 详情区外壳不留上/下间距,由 .detail-panel 自身控制(对齐 stock/external_stock) */
padding: 0 10px;
overflow: auto;
:deep(.el-descriptions__label) {
width: 100px;
}
.detail-page {
height: 100%;
overflow: auto;
}
/* 基础信息面板:分区标题 + 带边框描述列表(对齐 stock/external_stock「基本信息」) */
.detail-page.detail-panel {
padding: 8px 0;
.section {
margin-bottom: 12px;
&:last-child {
margin-bottom: 0;
}
}
.section-title {
font-size: 14px;
font-weight: 600;
color: #303133;
margin-bottom: 10px;
padding-left: 8px;
border-left: 3px solid #409eff;
line-height: 1.4;
}
.detail-descriptions :deep(.el-descriptions__label) {
width: 100px;
background: #fafbfc;
font-weight: 500;
}
}
}
}

View File

@ -1,18 +1,18 @@
<template>
<div class="log-container">
<el-button-group class="toolbar-btn-group">
<el-button
type="primary"
size="small"
@click="fetchReceivingLogs"
title="刷新"
:loading="loading"
:disabled="!props.id"
class="toolbar-btn"
>
刷新
</el-button>
</el-button-group>
<div class="header-actions">
<div class="left-actions">
<el-button
size="small"
type="primary"
:loading="loading"
:disabled="!props.id"
@click="fetchReceivingLogs"
>
刷新
</el-button>
</div>
</div>
<div ref="tableHostRef" class="table-host">
<el-table
@ -191,19 +191,39 @@ function backData(row: any) {
</script>
<style scoped lang="scss">
/* 样式对齐 stock/external_stock「外部绑定」新样式:
header-actions(按钮行,间距 6px 对齐 toolbar) + table-host(自适应剩余高度) + 右对齐分页 */
.log-container {
height: 100%;
width: 100%;
padding: 6px 10px;
height: 100%;
padding: 6px 10px 8px;
overflow: hidden;
display: flex;
flex-direction: column;
background: #fff;
box-sizing: border-box;
}
.toolbar-btn-group {
flex-shrink: 0;
.header-actions {
display: flex;
justify-content: space-between;
align-items: center;
margin-bottom: 6px;
flex-shrink: 0;
gap: 4px;
flex-wrap: wrap;
}
.left-actions {
display: flex;
align-items: center;
gap: 6px;
/* 清除 Element Plus 默认按钮左边距,统一由 gap 控制等间距 */
:deep(.el-button) {
margin-left: 0;
margin-right: 0;
}
}
.table-host {
@ -218,8 +238,16 @@ function backData(row: any) {
display: flex;
justify-content: flex-end;
align-items: center;
margin-top: 8px;
padding-top: 4px;
margin-top: 6px;
/* 每页条数下拉框与 UpperTable 的分页器保持一致 */
:deep(.el-select--small) {
width: 80px;
}
:deep(.el-input__wrapper) {
padding: 0 4px;
}
}
:deep(.el-drawer__body) {

View File

@ -2949,7 +2949,13 @@ onUnmounted(() => {
.left-actions {
display: flex;
align-items: center;
gap: 8px;
gap: 6px;
/* 清除 Element Plus 默认按钮左边距,间距统一由 gap 控制(对齐 toolbar 的 6px) */
:deep(.el-button) {
margin-left: 0;
margin-right: 0;
}
}
.left-col {

View File

@ -598,8 +598,10 @@ async function handleExportSelected() {
<style scoped lang="scss">
@use "@/views/order/orderManagement/styles/order-sub.scss";
/* 详情区外壳与 stock/external_stock 保持一致:不留上/下间距(操作日志组件自带
padding: 6px 10px 8px),只保留左右 10px,避免与组件内边距叠加 */
.order-sub-container .main-content .lower-level .detail-container {
padding: 10px;
padding: 0 10px;
overflow: auto;
}

View File

@ -41,6 +41,33 @@ export function sortReportDetailKeys(keys: string[]) {
return [...head, ...tail]
}
/**
* 报表明细分区(对齐 stock/external_stock「基本信息」新表单设计)
* 未列出的字段统一归入「其他信息」,保持 sortReportDetailKeys 的兜底顺序
*/
export const REPORT_DETAIL_SECTIONS: { title: string; keys: string[] }[] = [
{ title: '货主与仓库', keys: ['store_name', 'store_id', 'warehouse_name', 'warehouse_id'] },
{ title: '商品信息', keys: ['stock_id', 'item_code', 'barcode', 'item_name'] },
{ title: '库存数量', keys: ['begin_total', 'inbound_total', 'outbound_total', 'end_total'] },
{ title: '统计区间', keys: ['start_time', 'end_time'] }
]
/** 明细字段 -> 分区列表(含「其他信息」兜底;空分区不返回) */
export function groupReportDetailKeys(keys: string[]): { title: string; keys: string[] }[] {
const ordered = sortReportDetailKeys(keys)
const used = new Set<string>()
const sections: { title: string; keys: string[] }[] = []
for (const section of REPORT_DETAIL_SECTIONS) {
const hit = section.keys.filter((k) => ordered.includes(k))
if (!hit.length) continue
sections.push({ title: section.title, keys: hit })
hit.forEach((k) => used.add(k))
}
const rest = ordered.filter((k) => !used.has(k))
if (rest.length) sections.push({ title: '其他信息', keys: rest })
return sections
}
export function formatReportNumber(val: unknown): string {
if (val === null || val === undefined || val === '') return '--'
const n = Number(val)

View File

@ -74,17 +74,26 @@
</el-tabs>
</div>
<div class="detail-container">
<div v-if="activeTab === 'detail'" class="detail-page">
<el-descriptions :column="2" border size="small">
<el-descriptions-item
v-for="key in detailKeys"
:key="key"
:label="fieldLabel(key)"
:span="isWideKey(key) ? 2 : 1"
<div v-if="activeTab === 'detail'" class="detail-page detail-panel">
<!-- 报表明细:分区展示(对齐 stock/external_stock「基本信息」新表单设计) -->
<div v-for="section in detailSections" :key="section.title" class="section">
<div class="section-title">{{ section.title }}</div>
<el-descriptions
:column="DETAIL_COLUMNS"
border
size="small"
class="detail-descriptions"
>
{{ detailValue(key) }}
</el-descriptions-item>
</el-descriptions>
<el-descriptions-item
v-for="(key, index) in section.keys"
:key="key"
:label="fieldLabel(key)"
:span="detailSpan(section, key, index)"
>
{{ detailValue(key) }}
</el-descriptions-item>
</el-descriptions>
</div>
</div>
</div>
</div>
@ -134,6 +143,7 @@ import {
formatReportCell,
formatReportDateTime,
formatReportNumber,
groupReportDetailKeys,
normalizeScanConditionToReportWhere,
reportFieldLabels,
reportScanBoxAvailableFields,
@ -328,6 +338,22 @@ function fieldLabel(key: string) {
return reportFieldLabels[key] || key
}
/** 明细分区列数(对齐 stock/external_stock「基本信息」的 3 列描述列表) */
const DETAIL_COLUMNS = 3
/** 明细分区(每区一个 .section,含分区标题) */
const detailSections = computed(() =>
selectedRow.value ? groupReportDetailKeys(detailKeys.value) : []
)
/** 单元格占列数:超长文本独占整行;分区最后一行自动补齐,避免带边框表格缺角 */
function detailSpan(section: { keys: string[] }, key: string, index: number) {
if (isWideKey(key)) return DETAIL_COLUMNS
const rest = section.keys.length % DETAIL_COLUMNS
if (rest !== 0 && index === section.keys.length - 1) return DETAIL_COLUMNS - rest + 1
return 1
}
function detailValue(key: string) {
if (!selectedRow.value) return '--'
const v = (selectedRow.value as any)[key]
@ -761,20 +787,42 @@ onMounted(() => {
.detail-container {
flex: 1;
overflow: auto;
padding: 10px;
:deep(.el-descriptions__body) {
background: #fff;
}
:deep(.el-descriptions-item__cell) {
padding: 8px 12px;
}
/* 详情区外壳不留上/下间距,由 .detail-panel 自身控制(对齐 stock/external_stock) */
padding: 0 10px;
.detail-page {
height: 100%;
overflow: auto;
}
/* 报表明细面板:分区标题 + 带边框描述列表(对齐 stock/external_stock「基本信息」) */
.detail-page.detail-panel {
padding: 8px 0;
.section {
margin-bottom: 12px;
&:last-child {
margin-bottom: 0;
}
}
.section-title {
font-size: 14px;
font-weight: 600;
color: #303133;
margin-bottom: 10px;
padding-left: 8px;
border-left: 3px solid #409eff;
line-height: 1.4;
}
.detail-descriptions :deep(.el-descriptions__label) {
width: 120px;
background: #fafbfc;
font-weight: 500;
}
}
}
}

View File

@ -393,11 +393,7 @@
<el-dialog
v-model="updateExpressDialogVisible"
<<<<<<< HEAD
title="更新快递与运单号"
=======
title="更新快递公司与运单号"
>>>>>>> f4db2401638744bb2c1a5d132f23f0f470b76598
width="520px"
align-center
append-to-body
@ -412,31 +408,16 @@
:title="`更新出库单「${updateExpressTargetRow?.stockout_order_code || updateExpressTargetRow?.id || ''}」的运单号。`"
style="margin-bottom: 16px;"
/> -->
<el-alert
type="info"
:closable="false"
show-icon
title="快递公司填编码(如 SF/STO/ZT),运单号填 waybill_code;出库确认前必须已填写运单号。"
style="margin-bottom: 16px;"
/>
<el-form :model="updateExpressForm" label-width="100px">
<el-form-item label="快递公司">
<el-select
v-model="updateExpressForm.express_code"
<<<<<<< HEAD
placeholder="快递公司编码(如 SF/STO/ZT),清空则置空"
=======
placeholder="选择快递公司编码(如 SF/STO/ZT)"
>>>>>>> f4db2401638744bb2c1a5d132f23f0f470b76598
clearable
filterable
allow-create
default-first-option
<<<<<<< HEAD
style="width:100%"
=======
style="width: 100%"
>>>>>>> f4db2401638744bb2c1a5d132f23f0f470b76598
>
<el-option
v-for="opt in updateInfoExpressOptions"
@ -445,24 +426,14 @@
:value="opt.value"
/>
</el-select>
<<<<<<< HEAD
</el-form-item>
<el-form-item label="运单号">
<el-input v-model="updateExpressForm.waybill_code" placeholder="运单号(单个)" clearable />
=======
<div class="update-express-tip">传编码即可,后端自动解析快递名称;清空表示置空</div>
>>>>>>> f4db2401638744bb2c1a5d132f23f0f470b76598
</el-form-item>
<el-form-item label="运单号">
<el-input
v-model="updateExpressForm.waybill_codes"
type="textarea"
:rows="3"
<<<<<<< HEAD
placeholder="多包裹运单号,用逗号或换行分隔(可选)"
=======
placeholder="支持一单多运单,多个运单号用逗号、分号或换行分隔(可选)"
>>>>>>> f4db2401638744bb2c1a5d132f23f0f470b76598
/>
<div class="update-express-tip">清空后提交空数组,将清空原有运单号</div>
</el-form-item>
@ -491,11 +462,7 @@ import { safeInvoke } from '@/utils/safe-invoke'
import * as XLSX from 'xlsx'
import * as indexApi from '@/api/index/index'
import * as stockoutApi from '@/api/storage.stockout/stockout' //现有的对应API
<<<<<<< HEAD
import type { StockoutToOrderParams, StockoutUpdateExpressParams, StockoutUpdateInfoParams } from '@/api/storage.stockout/stockout'
=======
import type { StockoutToOrderParams, StockoutUpdateInfoParams, StockoutUpdateExpressParams, StockoutConfirmResponse } from '@/api/storage.stockout/stockout'
>>>>>>> f4db2401638744bb2c1a5d132f23f0f470b76598
import {
availableFields,
entryColums,
@ -827,40 +794,16 @@ async function handleSingleRowCancel(row: any) {
}
}
<<<<<<< HEAD
// ── 更新快递与运单号(storage.stockout.updateExpress)──
=======
// ── 更新快递公司与运单号(storage.stockout.updateExpress)──
>>>>>>> f4db2401638744bb2c1a5d132f23f0f470b76598
const updateExpressDialogVisible = ref(false)
const updateExpressLoading = ref(false)
const updateExpressTargetRow = ref<any>(null)
const updateExpressForm = reactive({
<<<<<<< HEAD
/** 快递公司编码(如 SF/STO/ZT),非运单号 */
express_code: '',
/** 运单号(单个) */
waybill_code: '',
/** 运单号列表(多包裹,文本按逗号/换行分隔) */
=======
/** 快递公司编码(express_code,非运单号) */
express_code: '',
/** 运单号多行文本,提交时拆分为 waybill_codes 数组 */
>>>>>>> f4db2401638744bb2c1a5d132f23f0f470b76598
waybill_codes: ''
})
/** 弹窗打开时的快递公司编码,用于判断是否需要提交 express_code(支持传空值置 NULL) */
let updateExpressOriginalExpressCode = ''
/** 运单号列表归一化为字符串数组(兼容 JSON 数组 / 分隔字符串) */
function normalizeWaybillCodes(v: any): string[] {
if (Array.isArray(v)) return v.map((item) => String(item).trim()).filter(Boolean)
if (v === null || v === undefined || v === '') return []
return String(v)
.split(/[,;,;\n]+/)
.map((s) => s.trim())
.filter(Boolean)
}
function openUpdateExpressDialog() {
const rows = selectionRows.value
@ -876,14 +819,7 @@ function openUpdateExpressDialog() {
updateExpressTargetRow.value = row
// 快递公司编码回填;运单号以 waybill_codes 为准(兼容单数 waybill_code)
updateExpressForm.express_code = String(row?.express_code ?? '')
<<<<<<< HEAD
updateExpressOriginalExpressCode = updateExpressForm.express_code
updateExpressForm.waybill_code = String(row?.waybill_code ?? '')
updateExpressForm.waybill_codes = normalizeWaybillCodes(row?.waybill_codes).join('\n')
// 快递公司下拉复用「修改出库单信息」的 index.getExpressList 选项,首次打开时加载
=======
updateExpressForm.waybill_codes = normalizeStockoutWaybillCodes(row).join('\n')
>>>>>>> f4db2401638744bb2c1a5d132f23f0f470b76598
if (!updateInfoExpressOptions.value.length) void loadUpdateInfoSelectOptions()
updateExpressDialogVisible.value = true
}
@ -892,19 +828,6 @@ async function handleUpdateExpressSubmit() {
const row = updateExpressTargetRow.value
if (!row) return
<<<<<<< HEAD
const payload: StockoutUpdateExpressParams = { id: row.id }
// express_code 是快递公司编码:传空值可将 express_code / express_name 置 NULL,
// 因此仅在值发生变化时提交,避免误清空
const expressCode = updateExpressForm.express_code.trim()
if (expressCode !== updateExpressOriginalExpressCode.trim()) payload.express_code = expressCode
const waybillCode = updateExpressForm.waybill_code.trim()
if (waybillCode) payload.waybill_code = waybillCode
const waybillCodes = normalizeWaybillCodes(updateExpressForm.waybill_codes)
if (waybillCodes.length) payload.waybill_codes = waybillCodes
if (payload.express_code === undefined && !payload.waybill_code && !payload.waybill_codes) {
=======
// 未传入的字段不会被更新;与原值不同才提交(空值表示清空)
const payload: StockoutUpdateExpressParams = { id: Number(row.id) }
let changed = false
@ -923,7 +846,6 @@ async function handleUpdateExpressSubmit() {
}
if (!changed) {
>>>>>>> f4db2401638744bb2c1a5d132f23f0f470b76598
ElMessage.warning('没有需要更新的字段')
return
}
@ -932,22 +854,12 @@ async function handleUpdateExpressSubmit() {
try {
const res: any = await stockoutApi.stockoutUpdateExpress(payload)
if (res && (res.code === 1 || res.code === 200 || res.code === 20000 || res.flag === 'success')) {
<<<<<<< HEAD
const data = res?.data || res
// 用响应同步当前行展示(列表字段与接口字段同名)
if (data?.express_code !== undefined) row.express_code = data.express_code
if (data?.express_name !== undefined) row.express_name = data.express_name
if (data?.waybill_code !== undefined) row.waybill_code = data.waybill_code
if (data?.waybill_codes !== undefined) row.waybill_codes = data.waybill_codes
ElMessage.success('快递与运单号更新成功')
=======
const data = res.data ?? res
const expressName = String(data?.express_name ?? '').trim()
const codeCount = Array.isArray(data?.waybill_codes) ? data.waybill_codes.length : 0
ElMessage.success(
`更新成功${expressName ? `:${expressName}` : ''}${codeCount ? `(${codeCount} 个运单号)` : ''}`
)
>>>>>>> f4db2401638744bb2c1a5d132f23f0f470b76598
updateExpressDialogVisible.value = false
loadData()
} else {
@ -1203,17 +1115,10 @@ async function fetchPrintData(row: any, _index: number) {
// 其余单据信息
stockout_order_code: row.stockout_order_code || '',
express_code: row.express_code || '',
<<<<<<< HEAD
waybill_code: row.waybill_code || '',
waybill_codes: row.waybill_codes || '',
// 旧字段(已废弃),保留以兼容历史模板
express_codes: row.express_codes || '',
=======
// 运单号:模板字段名 express_codes 保留以兼容旧模板,取值以 waybill_codes 口径为准
express_codes: waybillCodes.join(','),
waybill_code: waybillCodes[0] || '',
waybill_codes: waybillCodes.join(','),
>>>>>>> f4db2401638744bb2c1a5d132f23f0f470b76598
order_type: row.order_type || '',
source_type: row.source_type || '',
order_status: row.order_status || '',
@ -1261,15 +1166,9 @@ async function fetchPrintData(row: any, _index: number) {
create_at: pick(['create_at', 'created_at'], formData.create_at),
stockout_order_code: order.stockout_order_code || formData.stockout_order_code,
express_code: order.express_code ?? formData.express_code,
<<<<<<< HEAD
waybill_code: order.waybill_code ?? formData.waybill_code,
waybill_codes: order.waybill_codes ?? formData.waybill_codes,
express_codes: order.express_codes ?? formData.express_codes,
=======
express_codes: orderWaybillCodes.length ? orderWaybillCodes.join(',') : formData.express_codes,
waybill_code: orderWaybillCodes[0] || formData.waybill_code,
waybill_codes: orderWaybillCodes.length ? orderWaybillCodes.join(',') : formData.waybill_codes,
>>>>>>> f4db2401638744bb2c1a5d132f23f0f470b76598
order_type: order.order_type ?? formData.order_type,
source_type: order.source_type ?? formData.source_type,
order_status: order.order_status ?? formData.order_status,
@ -1401,19 +1300,6 @@ async function handleSingleRowStockout(row: any) {
} else {
ElMessage.success('出库成功')
}
<<<<<<< HEAD
if (data?.expressCodes) {
row.express_codes = data.expressCodes
}
if (data?.waybillCode) {
row.waybill_code = data.waybillCode
}
if (data?.waybillCodes) {
row.waybill_codes = data.waybillCodes
}
ElMessage.success('出库成功')
=======
>>>>>>> f4db2401638744bb2c1a5d132f23f0f470b76598
loadData()
} else {
ElMessage.error(res?.message || '出库失败')

View File

@ -159,22 +159,6 @@ export function formatDateTime(dateStr: string): string {
}
}
<<<<<<< HEAD
// 运单号列:优先 waybill_code / waybill_codes(当前接口字段),兼容旧字段 express_codes(数组或分隔字符串),去重后展示
export function formatExpressCodes(row: any): string {
const flatten = (v: any): string[] => {
if (v === null || v === undefined || v === '') return []
if (Array.isArray(v)) {
return v.map(item => String(item).trim()).filter(Boolean)
}
return String(v)
.split(/[,;,;\n]+/)
.map(s => s.trim())
.filter(Boolean)
}
const codes = [...flatten(row?.waybill_code), ...flatten(row?.waybill_codes), ...flatten(row?.express_codes)]
const unique = [...new Set(codes)]
=======
/** 运单号拆分:支持数组、以及逗号/分号/顿号/换行分隔的字符串 */
export function splitStockoutWaybillCodes(value: unknown): string[] {
if (value === null || value === undefined || value === '') return []
@ -210,7 +194,6 @@ export function isSameStockoutWaybillCodes(a: string[], b: string[]): boolean {
// 运单号列:以 waybill_codes 为准,回退单数 waybill_code / 旧 express_codes(数组或分隔字符串),去重后展示
export function formatExpressCodes(row: any): string {
const unique = normalizeStockoutWaybillCodes(row, { includeLegacy: true })
>>>>>>> f4db2401638744bb2c1a5d132f23f0f470b76598
if (!unique.length) return '--'
const escapeHtml = (s: string) =>
s.replace(/&/g, '&amp;').replace(/</g, '&lt;').replace(/>/g, '&gt;').replace(/"/g, '&quot;')

View File

@ -153,14 +153,14 @@ export const FIELD_DICT: Record<string, FieldDefinition> = {
slot: null,
detailLabel: '关键词'
},
id: {
key: 'id',
label: 'ID',
scanBox: null,
table: { width: 80, sortable: true },
slot: null,
detailLabel: 'ID'
},
// id: {
// key: 'id',
// label: 'ID',
// scanBox: null,
// table: { width: 80, sortable: true },
// slot: null,
// detailLabel: 'ID'
// },
server_name: {
key: 'server_name',
label: '所属服务器',

View File

@ -152,14 +152,14 @@ export const FIELD_DICT: Record<string, FieldDefinition> = {
slot: null,
detailLabel: '关键词'
},
id: {
key: 'id',
label: 'ID',
scanBox: null,
table: { width: 80, sortable: true },
slot: null,
detailLabel: 'ID'
},
// id: {
// key: 'id',
// label: 'ID',
// scanBox: null,
// table: { width: 80, sortable: true },
// slot: null,
// detailLabel: 'ID'
// },
name: {
key: 'name',
label: '服务器名称',

View File

@ -152,81 +152,100 @@
</div>
<div class="detail-container">
<el-descriptions v-if="activeTab === 'details'" :column="2" border size="small">
<el-descriptions-item label="签约ID">{{ selectedRow.id }}</el-descriptions-item>
<el-descriptions-item label="签约状态">
<span :class="getStatusTextClass(getAuthStatusType(selectedRow.auth_status))">
{{ selectedRow.auth_status_label || getAuthStatusLabel(selectedRow.auth_status) }}
</span>
</el-descriptions-item>
<el-descriptions-item label="签约仓库">{{ selectedRow.warehouse_name || selectedRow.remask || selectedRow.counterparty_name || '—' }}</el-descriptions-item>
<el-descriptions-item v-if="currentSubject.company_name" label="当前货主">
{{ currentSubject.company_name }}
<el-tag size="small" type="warning" effect="plain" style="margin-left:6px">货主方</el-tag>
</el-descriptions-item>
<el-descriptions-item label="仓库ID">{{ selectedRow.warehouse_id }}</el-descriptions-item>
<el-descriptions-item label="使用状态">
<span :class="getStatusTextClass(selectedRow.use_status === 1 ? 'success' : 'info')">
{{ selectedRow.use_status === 1 ? '启用' : '禁用' }}
</span>
</el-descriptions-item>
<el-descriptions-item label="授权截止">
<span :class="{ 'text-danger': isExpired(selectedRow.auth_end) }">{{ selectedRow.auth_end || '—' }}</span>
</el-descriptions-item>
<el-descriptions-item label="面单余额">{{ selectedRow.print_quantity ?? '—' }}</el-descriptions-item>
<el-descriptions-item label="奇门配置">
<span :class="getStatusTextClass(selectedRow.has_qimen_config ? 'success' : 'info')">
{{ selectedRow.has_qimen_config ? '已配置' : '未配置' }}
</span>
</el-descriptions-item>
</el-descriptions>
<div v-else class="log-placeholder">
<div class="log-toolbar">
<div v-if="activeTab === 'details'" class="detail-panel">
<!-- 签约主体 -->
<div class="section">
<div class="section-title">签约主体</div>
<el-descriptions :column="2" border size="small" class="detail-descriptions">
<el-descriptions-item v-if="currentSubject.company_name" label="当前货主">
{{ currentSubject.company_name }}
<el-tag size="small" type="warning" effect="plain" style="margin-left:6px">货主方</el-tag>
</el-descriptions-item>
<el-descriptions-item label="签约仓库" :span="currentSubject.company_name ? 1 : 2">
{{ selectedRow.warehouse_name || selectedRow.remask || selectedRow.counterparty_name || '—' }}
</el-descriptions-item>
</el-descriptions>
</div>
<!-- 签约信息 -->
<div class="section">
<div class="section-title">签约信息</div>
<el-descriptions :column="3" border size="small" class="detail-descriptions">
<el-descriptions-item label="签约ID">{{ selectedRow.id ?? '—' }}</el-descriptions-item>
<el-descriptions-item label="签约状态">
<span :class="getStatusTextClass(getAuthStatusType(selectedRow.auth_status))">
{{ selectedRow.auth_status_label || getAuthStatusLabel(selectedRow.auth_status) }}
</span>
</el-descriptions-item>
<el-descriptions-item label="仓库ID">{{ selectedRow.warehouse_id ?? '—' }}</el-descriptions-item>
<el-descriptions-item label="使用状态">
<span :class="getStatusTextClass(selectedRow.use_status === 1 ? 'success' : 'info')">
{{ selectedRow.use_status === 1 ? '启用' : '禁用' }}
</span>
</el-descriptions-item>
<el-descriptions-item label="授权截止">
<span :class="{ 'text-danger': isExpired(selectedRow.auth_end) }">{{ selectedRow.auth_end || '—' }}</span>
</el-descriptions-item>
<el-descriptions-item label="面单余额">{{ selectedRow.print_quantity ?? '—' }}</el-descriptions-item>
<el-descriptions-item label="奇门配置" :span="3">
<span :class="getStatusTextClass(selectedRow.has_qimen_config ? 'success' : 'info')">
{{ selectedRow.has_qimen_config ? '已配置' : '未配置' }}
</span>
</el-descriptions-item>
</el-descriptions>
</div>
</div>
<div v-else class="log-panel">
<div class="header-actions">
<div class="left-actions">
<el-button size="small" type="primary" :loading="logLoading" @click="loadLogs">刷新</el-button>
</div>
</div>
<div ref="logTableHostRef" class="table-host">
<el-table
:data="logList"
v-loading="logLoading"
border
stripe
style="width: 100%"
:height="logTableHeight"
>
<el-table-column prop="id" label="ID" width="70" />
<el-table-column prop="business_type" label="业务类型" min-width="100">
<template #default="{ row }">{{ row.business_type || '—' }}</template>
</el-table-column>
<el-table-column prop="change_quantity" label="变更数量" width="100" />
<el-table-column prop="before_quantity" label="变更前面单余额" width="130" />
<el-table-column prop="after_quantity" label="变更后面单余额" width="130" />
<el-table-column prop="reason" label="变更原因" min-width="140">
<template #default="{ row }">{{ row.reason || '—' }}</template>
</el-table-column>
<el-table-column prop="operator_name" label="操作人" width="100">
<template #default="{ row }">{{ row.operator_name || '—' }}</template>
</el-table-column>
<el-table-column prop="created_at" label="操作时间" width="170">
<template #default="{ row }">{{ row.created_at || '—' }}</template>
</el-table-column>
<template #empty>
<div class="empty-tip">暂无操作日志</div>
</template>
</el-table>
</div>
<div class="pagination-container">
<el-pagination
v-if="logPagination.total > 0"
v-model:current-page="logPagination.currentPage"
v-model:page-size="logPagination.pageSize"
:total="logPagination.total"
:page-sizes="[10, 20, 50]"
layout="total, sizes, prev, pager, next"
:page-sizes="[10, 20, 50, 100]"
layout="total, sizes, prev, pager, next, jumper"
background
size="small"
@current-change="loadLogs"
@size-change="handleLogSizeChange"
/>
</div>
<el-table :data="logList" v-loading="logLoading" size="small" border max-height="220">
<el-table-column prop="id" label="ID" width="70" />
<el-table-column prop="business_type" label="业务类型" min-width="100">
<template #default="{ row }">{{ row.business_type || '—' }}</template>
</el-table-column>
<el-table-column prop="change_quantity" label="变更数量" width="100" />
<el-table-column prop="before_quantity" label="变更前面单余额" width="130" />
<el-table-column prop="after_quantity" label="变更后面单余额" width="130" />
<el-table-column prop="reason" label="变更原因" min-width="140">
<template #default="{ row }">{{ row.reason || '—' }}</template>
</el-table-column>
<el-table-column prop="operator_name" label="操作人" width="100">
<template #default="{ row }">{{ row.operator_name || '—' }}</template>
</el-table-column>
<el-table-column prop="created_at" label="操作时间" width="170">
<template #default="{ row }">{{ row.created_at || '—' }}</template>
</el-table-column>
<template #empty>
<el-empty description="暂无操作日志" :image-size="40" />
</template>
</el-table>
<el-pagination
v-if="logPagination.total > 0"
v-model:current-page="logPagination.currentPage"
v-model:page-size="logPagination.pageSize"
:total="logPagination.total"
:page-sizes="[10, 20, 50]"
layout="total, sizes, prev, pager, next"
size="small"
style="margin-top:8px;justify-content:flex-end"
@current-change="loadLogs"
@size-change="handleLogSizeChange"
/>
</div>
</div>
</div>
@ -430,6 +449,7 @@
<script setup lang="ts">
import { ref, reactive, onMounted, computed, watch } from 'vue'
import { ElMessage, ElMessageBox } from 'element-plus'
import { useResizeObserver } from '@vueuse/core'
import {
warehouseList,
storeWarehouseSign,
@ -610,6 +630,28 @@ const logLoading = ref(false)
const logList = ref<any[]>([])
const logPagination = reactive({ currentPage: 1, pageSize: 20, total: 0 })
/* 表格高度:由容器实际高度驱动(Element Plus 不支持 height="100%") */
const logTableHostRef = ref<HTMLElement | null>(null)
const logTableHeight = ref(220)
useResizeObserver(logTableHostRef, (entries) => {
const h = entries[0]?.contentRect.height ?? 0
if (h >= 100) {
logTableHeight.value = Math.floor(h)
}
})
/** 切 tab / 切行后用 rAF 兜底测高 */
function syncLogTableHeight() {
requestAnimationFrame(() => {
const el = logTableHostRef.value
if (el) {
const h = el.getBoundingClientRect().height
if (h >= 100) logTableHeight.value = Math.floor(h)
}
})
}
// ─── 导出日志(异步任务) ──────────────────────────────────────────────────
const {
exportLoading,
@ -1043,6 +1085,7 @@ watch(activeTab, (val) => {
if (val === 'logs' && selectedRow.value) {
logPagination.currentPage = 1
loadLogs()
syncLogTableHeight()
}
})
@ -1050,6 +1093,7 @@ watch(selectedRow, (row) => {
if (row && activeTab.value === 'logs') {
logPagination.currentPage = 1
loadLogs()
syncLogTableHeight()
}
})
@ -1073,14 +1117,107 @@ onMounted(() => {
<style scoped lang="scss">
@use "../order/orderManagement/styles/order-sub.scss";
/* 详情区外壳与 storage/entry_owner 一致:不留上/下间距,左右 10px,
面板自身 padding: 6px 10px 8px(合计内容缩进 20px) */
.order-sub-container .main-content .lower-level .detail-container {
padding: 6px 10px;
padding: 0 10px;
display: flex;
flex-direction: column;
box-sizing: border-box;
overflow: auto;
flex: 1;
min-height: 0;
/* 签约详情:分区标题 + 带边框描述列表(对齐 stock/external_stock「基本信息」新设计) */
.detail-panel {
flex: 1;
min-height: 0;
padding: 6px 10px 8px;
box-sizing: border-box;
overflow: auto;
.section {
margin-bottom: 12px;
&:last-child {
margin-bottom: 0;
}
}
.section-title {
font-size: 14px;
font-weight: 600;
color: #303133;
margin-bottom: 10px;
padding-left: 8px;
border-left: 3px solid #409eff;
line-height: 1.4;
}
.detail-descriptions :deep(.el-descriptions__label) {
width: 110px;
background: #fafbfc;
font-weight: 500;
}
}
/* 操作日志:按钮行 + 自适应表格 + 右对齐分页(对齐 storage/entry_owner 的日志面板新设计) */
.log-panel {
flex: 1;
min-height: 0;
display: flex;
flex-direction: column;
padding: 6px 10px 8px;
overflow: hidden;
background: #fff;
box-sizing: border-box;
.header-actions {
display: flex;
justify-content: space-between;
align-items: center;
margin-bottom: 6px;
flex-shrink: 0;
gap: 4px;
flex-wrap: wrap;
.left-actions {
display: flex;
align-items: center;
gap: 6px;
/* 清除 Element Plus 默认按钮左边距,统一由 gap 控制等间距 */
:deep(.el-button) {
margin-left: 0;
margin-right: 0;
}
}
}
.table-host {
flex: 1;
min-height: 120px;
min-width: 0;
overflow: hidden;
}
.pagination-container {
flex-shrink: 0;
display: flex;
justify-content: flex-end;
align-items: center;
margin-top: 6px;
/* 每页条数下拉框与 UpperTable(列表页)的分页器保持一致 */
:deep(.el-select--small) {
width: 80px;
}
:deep(.el-input__wrapper) {
padding: 0 4px;
}
}
}
}
.empty-tip {