feat(order): B2B 备货作业窗口与提货设置接入
备货:行内「备货」打开作业窗口(startB2bPrep 激活),窗口内完成分箱登记(getB2bPackingSnapshot/updateB2bPackingItems,含取货储位)与备货完成(备货照片 updateB2bOrderImages + finishB2bPrep);齐套校验失败展示 item_mismatches;关闭窗口(含遮罩/ESC)统一提示取消备货(cancelB2bPrep)。 提货:确认提货进入操作列,车牌 + 提货照片随 pickupB2b 一次提交,提货即出库完成;已提货订单车牌锁定仅可追加照片。 列表:操作列按状态动态生成(备货/确认提货/设置车牌),移除独立分箱入口;B2B 列表补充作业创建时间、备货/提货照片;B2B 详情补充 b2b 作业明细、备货与提货照片分组展示。 其它:COS 图片上传兼容多层 data 包裹并回传 fileId;UpperTable 操作列宽度不受历史列配置覆盖。 Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This commit is contained in:
parent
0f99ca2477
commit
ade15558ca
@ -1,4 +1,5 @@
|
||||
import request from '@/utils/request'
|
||||
import type { OrderDetailB2bInfo, OrderDetailImage } from '@/api/order/order'
|
||||
|
||||
const v = '1.0'
|
||||
|
||||
@ -220,6 +221,12 @@ export type DeliveryOrderDetailPayload = {
|
||||
expresses?: DeliveryOrderDetailExpressItem[]
|
||||
logs?: DeliveryOrderDetailLogItem[]
|
||||
waybill_codes?: string[]
|
||||
/** B2B 作业明细:仅 is_b2b=Y 的订单输出,非 B2B 为 null */
|
||||
b2b?: OrderDetailB2bInfo | null
|
||||
/** B2B 备货留证照片(business_type=b2b_order);无图片为空数组 */
|
||||
images?: OrderDetailImage[]
|
||||
/** B2B 提货留证照片(business_type=b2b_pickup);无图片为空数组,与 images 分开输出 */
|
||||
pickup_images?: OrderDetailImage[]
|
||||
}
|
||||
|
||||
export function orderDeliveryOrderList(data: DeliveryOrderListParams = {}): Promise<any> {
|
||||
|
||||
@ -1,4 +1,5 @@
|
||||
import request from "@/utils/request";
|
||||
import type { OrderDetailB2bInfo, OrderDetailImage } from "@/api/order/order";
|
||||
import {
|
||||
orderModulePendingOrderDownloadCreateTemplate,
|
||||
orderModulePendingOrderManualWaybill,
|
||||
@ -68,16 +69,40 @@ export type PendingOrderListParams = {
|
||||
export type PendingOrderListResponse = PendingOrderWorkbenchListResponse;
|
||||
|
||||
export type PendingOrderDetailParams = {
|
||||
/** 订单ID:支持 ids 数组、逗号分隔字符串或单个 id/order_id,至少提供一项 */
|
||||
ids?: Array<number | string> | string | number;
|
||||
id?: number | string;
|
||||
order_id?: number | string;
|
||||
orderId?: number | string;
|
||||
/** 已忽略:接口固定先查配送表(dispatch),查不到再兜底待处理表(current),传入不生效 */
|
||||
tableType?: string;
|
||||
tablePosition?: string;
|
||||
type?: string;
|
||||
moduleName?: string;
|
||||
};
|
||||
|
||||
/**
|
||||
* order.pendingOrder.detail 响应 data
|
||||
* - B2B 订单(is_b2b='Y')额外返回副表作业明细 b2b、备货照片 images 与提货照片 pickup_images,
|
||||
* 非 B2B 时 b2b 为 null、images / pickup_images 为空数组
|
||||
*/
|
||||
export type PendingOrderDetailPayload = {
|
||||
/** 订单头对象(raw 行数据,来自配送表或兜底的待处理表) */
|
||||
detail?: Record<string, any>;
|
||||
order?: Record<string, any>;
|
||||
orderItems?: Record<string, any>[];
|
||||
items?: Record<string, any>[];
|
||||
expresses?: Record<string, any>[];
|
||||
/** 按库位平铺的储位分配明细 */
|
||||
storage_items?: Record<string, any>[];
|
||||
/** B2B 作业明细:仅 is_b2b=Y 的订单输出,非 B2B 为 null */
|
||||
b2b?: OrderDetailB2bInfo | null;
|
||||
/** B2B 备货留证照片(business_type=b2b_order);无图片为空数组 */
|
||||
images?: OrderDetailImage[];
|
||||
/** B2B 提货留证照片(business_type=b2b_pickup);无图片为空数组,与 images 分开输出 */
|
||||
pickup_images?: OrderDetailImage[];
|
||||
};
|
||||
|
||||
/** markPendingOutboundOrder / cancelOrder:文档要求订单 ID 正整数数组,不支持单 id 或逗号字符串 */
|
||||
export type PendingOrderIdsParams = {
|
||||
ids: number[];
|
||||
@ -353,6 +378,9 @@ export function orderPendingOrderList(data: PendingOrderListParams = {}): Promis
|
||||
* total_box_count、pickup_plate_number、prep_remark、prep_duration_seconds、is_urgent(Y/N)、prep_at、
|
||||
* is_picked_up(Y/N)、picked_up_at、created_at(作业明细创建时间,与订单 create_at 不同)、
|
||||
* prep_status(none/padding/fin)、prep_operator_id、prep_operator_name、prep_start_at
|
||||
* - 行内另带出 images(备货留证照片 business_type=b2b_order)、pickup_images(提货留证照片 b2b_pickup),
|
||||
* 元素 { id: file_id, url, display_order };无图片为空数组
|
||||
* - 取货储位不在列表返回:逐商品取货储位见 order.getB2bPackingSnapshot 的 items[].pick_locations
|
||||
* - where 额外支持(仅 B2B 列表开放,普通列表不识别):total_box_count / pickup_plate_number / prep_remark /
|
||||
* prep_duration_seconds / is_picked_up / picked_up_at / created_at / prep_at / is_urgent /
|
||||
* prep_status / prep_operator_id / prep_start_at(支持简写与 {operator,value} 标准结构,prep_at 支持 between)
|
||||
@ -373,6 +401,28 @@ export function orderPendingOrder2bList(data: PendingOrderListParams = {}): Prom
|
||||
} as any);
|
||||
}
|
||||
|
||||
/** order.pendingOrder2b.list 列表行(在普通订单行基础上追加 B2B 作业字段与照片) */
|
||||
export type PendingOrderB2bListRow = Record<string, any> & {
|
||||
prep_status?: string;
|
||||
prep_operator_id?: number | null;
|
||||
prep_operator_name?: string | null;
|
||||
prep_start_at?: string | null;
|
||||
total_box_count?: number;
|
||||
pickup_plate_number?: string | null;
|
||||
prep_remark?: string | null;
|
||||
prep_duration_seconds?: number;
|
||||
prep_at?: string | null;
|
||||
is_urgent?: string;
|
||||
is_picked_up?: string;
|
||||
picked_up_at?: string | null;
|
||||
/** B2B 作业明细创建时间(与订单 create_at 不同) */
|
||||
created_at?: string | null;
|
||||
/** 备货留证照片(business_type=b2b_order) */
|
||||
images?: OrderDetailImage[];
|
||||
/** 提货留证照片(business_type=b2b_pickup) */
|
||||
pickup_images?: OrderDetailImage[];
|
||||
};
|
||||
|
||||
/**
|
||||
* order.convertToB2b:待处理订单批量转 B2B 订单
|
||||
* - 仅查当前仓库 current 分表(wms_order_delivery_{warehouseId}),仓库取自登录上下文,禁止前端传入
|
||||
@ -487,6 +537,25 @@ export type PendingOrderB2bOrderIdParams = {
|
||||
orderId?: number;
|
||||
};
|
||||
|
||||
/**
|
||||
* B2B 照片入参项:可直接传 file_id,或传 { file_id, display_order }
|
||||
* (display_order 缺省按去重后下标补 0 起序号)
|
||||
*/
|
||||
export type PendingOrderB2bImageInput =
|
||||
| number
|
||||
| { file_id: number; display_order?: number };
|
||||
|
||||
/**
|
||||
* B2B 照片项(接口响应内):order.pickupB2b / order.updateB2bOrderImages 返回 { file_id, url, display_order };
|
||||
* 明细与列表的 images / pickup_images 返回 { id: file_id, url, display_order }(见 OrderDetailImage)
|
||||
*/
|
||||
export type PendingOrderB2bImageItem = {
|
||||
/** file_id */
|
||||
file_id: number | string;
|
||||
url: string;
|
||||
display_order?: number;
|
||||
};
|
||||
|
||||
/**
|
||||
* order.startB2bPrep:备货开始(仅 B2B 订单,单订单作业)
|
||||
* - 操作人取当前登录工号写入 prep_operator_id / prep_operator_name,prep_status 置 padding,prep_start_at 记开始时间
|
||||
@ -556,6 +625,8 @@ export function orderPendingOrderCancelB2bPrep(
|
||||
* - 写入 prep_remark / total_box_count / prep_at(提交时刻)/ prep_duration_seconds,prep_status 置 fin
|
||||
* - 仅 prep_status=padding 可提交,且必须由同一备货工号提交
|
||||
* - ⚠️ 完成时**同步扣减库存**(口径同拣货完成:扣 wms_storage 锁定+可用、写 OUTBOUND/PICK_OUTBOUND 流水、wms_picking 置 fin)
|
||||
* - 仓库开启 subject_config.b2b_packing_quantity_check 时,逐商品行校验分箱数量合计 = plan_qty,
|
||||
* 并校验 total_box_count = 分箱箱号数;不符返回 400(data.item_mismatches),事务回滚
|
||||
*/
|
||||
export type PendingOrderFinishB2bPrepParams = PendingOrderB2bOrderIdParams & {
|
||||
/** 备货备注,必填,最长 500 字符 */
|
||||
@ -566,6 +637,19 @@ export type PendingOrderFinishB2bPrepParams = PendingOrderB2bOrderIdParams & {
|
||||
totalBoxCount?: number;
|
||||
};
|
||||
|
||||
/** order.finishB2bPrep 齐套校验失败明细项(data.item_mismatches) */
|
||||
export type PendingOrderFinishB2bPrepMismatch = {
|
||||
/** 订单商品明细ID */
|
||||
order_item_id?: number;
|
||||
item_id?: number | null;
|
||||
item_code?: string | null;
|
||||
item_name?: string | null;
|
||||
/** 应拣数量 */
|
||||
plan_qty?: number;
|
||||
/** 已分箱数量合计 */
|
||||
packed_quantity?: number;
|
||||
};
|
||||
|
||||
/** order.finishB2bPrep 响应 */
|
||||
export type PendingOrderFinishB2bPrepResponse = {
|
||||
/** 固定 fin */
|
||||
@ -603,9 +687,20 @@ export function orderPendingOrderFinishB2bPrep(
|
||||
/**
|
||||
* order.pickupB2b:B2B 提货(仅 B2B 订单,单订单作业)
|
||||
* - is_picked_up 置 Y、picked_up_at 记提交时刻;要求 is_b2b=Y、未取消、prep_status=fin
|
||||
* - 已提货重复调用幂等成功并返回首次提货时间(already_picked_up=true)
|
||||
* - **提货即出库完成**:同一事务把订单所在分表的 outbound_status 置 fin、step 置 4、delivery_time 置提货时间,
|
||||
* 随后由出库迁移调度搬到配送表(dispatch_lane=m4),可从 order.deliveryOrder2b.list 查询
|
||||
* - 已提货重复调用幂等成功并返回首次提货时间(already_picked_up=true);已提货但主表未出库的历史单会补写(自愈)
|
||||
* - 订单先在 current 分表查,未命中兜底 dispatch 分表
|
||||
* - 可选 pickup_plate_number:提货时一并写入提货车牌(空串/null 清空;已提货时传不同值返回 400)
|
||||
* - 可选 pickup_file_ids:提货照片(追加语义,写入 business_type=b2b_pickup,不覆盖已有照片)
|
||||
*/
|
||||
export type PendingOrderPickupB2bParams = PendingOrderB2bOrderIdParams & {
|
||||
/** 提货车牌(可选;归一化后写入 wms_order_b2b.pickup_plate_number) */
|
||||
pickup_plate_number?: string | null;
|
||||
/** 提货照片 file_id 列表(可选;兼容 pickupFileIds / file_ids / fileIds / pickup_images) */
|
||||
pickup_file_ids?: PendingOrderB2bImageInput[];
|
||||
};
|
||||
|
||||
export type PendingOrderPickupB2bResponse = {
|
||||
/** 固定 Y */
|
||||
is_picked_up: string;
|
||||
@ -617,10 +712,22 @@ export type PendingOrderPickupB2bResponse = {
|
||||
picked_up_count: number;
|
||||
/** true=已提货幂等命中(未改写提货时间与操作日志) */
|
||||
already_picked_up: boolean;
|
||||
/** 订单当前提货车牌:本次传入为新值,未传为库中已有值,均无时为 null */
|
||||
pickup_plate_number?: string | null;
|
||||
/** 订单当前提货照片(business_type=b2b_pickup),无照片为空数组 */
|
||||
pickup_images: PendingOrderB2bImageItem[];
|
||||
/** 订单当前提货照片数量 */
|
||||
pickup_image_count: number;
|
||||
/** 提货后订单主表出库状态,固定 fin */
|
||||
outbound_status: string;
|
||||
/** 提货后订单主表步骤,固定 4(已出库,等待迁移到配送表) */
|
||||
step: number;
|
||||
/** 本次调用是否写入了主表出库状态(已提货且主表已完成出库时为 false) */
|
||||
outbound_marked: boolean;
|
||||
};
|
||||
|
||||
export function orderPendingOrderPickupB2b(
|
||||
data: PendingOrderB2bOrderIdParams,
|
||||
data: PendingOrderPickupB2bParams,
|
||||
): Promise<any> {
|
||||
return request({
|
||||
url: "/system",
|
||||
@ -716,6 +823,199 @@ export function orderPendingOrderCancelB2bUrgent(
|
||||
} as any);
|
||||
}
|
||||
|
||||
/**
|
||||
* order.setB2bPickupPlate:录入/修改 B2B 提货车牌(仅 B2B 订单,单订单作业,提货前可改)
|
||||
* - 车牌归一化(去空格与 ·/•/-/-/_ 分隔符后转大写)后写入 wms_order_b2b.pickup_plate_number
|
||||
* - pickup_plate_number 键必须传;传空字符串或 null 表示清空车牌
|
||||
* - 仅 is_b2b=Y 且未取消的订单可录入;已提货(is_picked_up=Y)后车牌锁定不允许再修改
|
||||
* - 作业明细行缺失时按默认值补建(detail_created=true)
|
||||
*/
|
||||
export type PendingOrderSetB2bPickupPlateParams = {
|
||||
/** 订单ID:单订单作业,仅允许传 1 个(单值或单元素数组) */
|
||||
ids: number[];
|
||||
/** 提货车牌;空字符串或 null 表示清空 */
|
||||
pickup_plate_number: string | null;
|
||||
};
|
||||
|
||||
export type PendingOrderSetB2bPickupPlateResponse = {
|
||||
order_id: number;
|
||||
delivery_order_code: string;
|
||||
/** 本次落库的车牌(归一化后);清空时为 null */
|
||||
pickup_plate_number: string | null;
|
||||
/** 修改前的车牌;原本无车牌时为 null */
|
||||
previous_pickup_plate_number: string | null;
|
||||
/** 车牌是否发生变化(false 表示与原值一致,未重复写操作日志) */
|
||||
changed: boolean;
|
||||
/** 作业明细行是否本次补建(true=原无 wms_order_b2b 行) */
|
||||
detail_created: boolean;
|
||||
};
|
||||
|
||||
export function orderPendingOrderSetB2bPickupPlate(
|
||||
data: PendingOrderSetB2bPickupPlateParams,
|
||||
): Promise<PendingOrderSetB2bPickupPlateResponse> {
|
||||
return request({
|
||||
url: "/system",
|
||||
method: "post",
|
||||
params: {
|
||||
method: "order.setB2bPickupPlate",
|
||||
v,
|
||||
timestamp: Date.now(),
|
||||
},
|
||||
data,
|
||||
isSystemApi: true,
|
||||
} as any);
|
||||
}
|
||||
|
||||
/**
|
||||
* order.updateB2bOrderImages:更新 B2B 订单备货留证照片(单订单,全量覆盖)
|
||||
* - business_type 固定 b2b_order(与提货照片 b2b_pickup 分开存放)
|
||||
* - images 全量覆盖语义,传 [] 清空;单订单最多 20 张;文件必须属于当前仓库且未删除
|
||||
*/
|
||||
export type PendingOrderUpdateB2bOrderImagesParams = {
|
||||
/** 订单ID:单订单作业,仅允许传 1 个(单值或单元素数组) */
|
||||
ids: number[];
|
||||
/** 备货照片列表(全量覆盖;支持 file_id 或 { file_id, display_order }) */
|
||||
images: PendingOrderB2bImageInput[];
|
||||
};
|
||||
|
||||
export type PendingOrderUpdateB2bOrderImagesResponse = {
|
||||
order_id: number;
|
||||
delivery_order_code: string;
|
||||
image_count: number;
|
||||
/** 更新后的备货照片列表(按 display_order、id 升序) */
|
||||
images: PendingOrderB2bImageItem[];
|
||||
added_file_ids: number[];
|
||||
removed_file_ids: number[];
|
||||
};
|
||||
|
||||
export function orderPendingOrderUpdateB2bOrderImages(
|
||||
data: PendingOrderUpdateB2bOrderImagesParams,
|
||||
): Promise<PendingOrderUpdateB2bOrderImagesResponse> {
|
||||
return request({
|
||||
url: "/system",
|
||||
method: "post",
|
||||
params: {
|
||||
method: "order.updateB2bOrderImages",
|
||||
v,
|
||||
timestamp: Date.now(),
|
||||
},
|
||||
data,
|
||||
isSystemApi: true,
|
||||
} as any);
|
||||
}
|
||||
|
||||
/**
|
||||
* order.getB2bPackingSnapshot:查询单个 B2B 订单的商品明细与分箱快照
|
||||
* - items 每项含 order_item_id / plan_qty / packed_quantity / boxes({ box_no, quantity })
|
||||
* 以及 pick_locations(该商品从哪些储位取货多少:{ space_id, space_name, quantity })
|
||||
* - pick_location_count:本单涉及的不同储位个数(wms_picking 排除 status=cancel,未分配储位为 0)
|
||||
* - require_packing_quantity_match:当前仓库是否开启分箱齐套校验(subject_config.b2b_packing_quantity_check)
|
||||
*/
|
||||
export type PendingOrderB2bPackingBox = {
|
||||
box_no: string;
|
||||
quantity: number;
|
||||
};
|
||||
|
||||
/** 逐商品取货储位(wms_picking 排除 status=cancel,同商品同储位合并数量) */
|
||||
export type PendingOrderB2bPackingPickLocation = {
|
||||
space_id: number | string;
|
||||
space_name: string;
|
||||
/** 该商品在此储位的取货数量 */
|
||||
quantity: number;
|
||||
};
|
||||
|
||||
export type PendingOrderB2bPackingSnapshotItem = {
|
||||
order_item_id: number;
|
||||
item_id?: number | null;
|
||||
stock_id?: number | null;
|
||||
item_code?: string | null;
|
||||
item_name?: string | null;
|
||||
item_snapshot?: Record<string, any> | null;
|
||||
/** 应拣数量(订单明细 plan_qty) */
|
||||
plan_qty: number;
|
||||
/** 已分箱数量 */
|
||||
packed_quantity: number;
|
||||
boxes: PendingOrderB2bPackingBox[];
|
||||
/** 该商品的取货储位(未分配储位时为空数组) */
|
||||
pick_locations: PendingOrderB2bPackingPickLocation[];
|
||||
};
|
||||
|
||||
export type PendingOrderB2bPackingSnapshot = {
|
||||
order_id: number;
|
||||
delivery_order_code: string;
|
||||
status?: string;
|
||||
/** 备货状态,无作业明细时为 none */
|
||||
prep_status: string;
|
||||
total_box_count: number;
|
||||
/** 取货储位数量(本单涉及的不同储位个数),未分配储位时为 0 */
|
||||
pick_location_count: number;
|
||||
/** 当前仓库是否启用分箱数量齐套校验 */
|
||||
require_packing_quantity_match: boolean;
|
||||
items: PendingOrderB2bPackingSnapshotItem[];
|
||||
};
|
||||
|
||||
export function orderPendingOrderGetB2bPackingSnapshot(
|
||||
data: PendingOrderB2bOrderIdParams,
|
||||
): Promise<PendingOrderB2bPackingSnapshot> {
|
||||
return request({
|
||||
url: "/system",
|
||||
method: "post",
|
||||
params: {
|
||||
method: "order.getB2bPackingSnapshot",
|
||||
v,
|
||||
timestamp: Date.now(),
|
||||
},
|
||||
data,
|
||||
isSystemApi: true,
|
||||
} as any);
|
||||
}
|
||||
|
||||
/**
|
||||
* order.updateB2bPackingItems:全量更新单个 B2B 订单的分箱商品明细
|
||||
* - 每条记录关联订单商品明细 order_item_id,记录箱号 box_no 与该箱数量 quantity
|
||||
* - 整单全量替换,items 传空数组可清空;同时按不同箱号数同步 wms_order_b2b.total_box_count
|
||||
* - 仅当前仓库的 B2B 且备货中(prep_status=padding)的订单可更新
|
||||
*/
|
||||
export type PendingOrderB2bPackingItem = {
|
||||
/** 订单商品明细ID */
|
||||
order_item_id: number;
|
||||
/** 箱号(最长 50 字符) */
|
||||
box_no: string;
|
||||
/** 该商品在该箱的正整数数量 */
|
||||
quantity: number;
|
||||
};
|
||||
|
||||
export type PendingOrderUpdateB2bPackingItemsParams = {
|
||||
/** 订单ID:仅允许传 1 个(单值或单元素数组) */
|
||||
ids: number[];
|
||||
/** 完整分箱明细(最多 10000 条;同一商品行与箱号不能重复) */
|
||||
items: PendingOrderB2bPackingItem[];
|
||||
};
|
||||
|
||||
export type PendingOrderUpdateB2bPackingItemsResponse = {
|
||||
order_id: number;
|
||||
/** 本次保存的分箱明细行数 */
|
||||
item_count: number;
|
||||
/** 不同箱号的数量 */
|
||||
box_count: number;
|
||||
};
|
||||
|
||||
export function orderPendingOrderUpdateB2bPackingItems(
|
||||
data: PendingOrderUpdateB2bPackingItemsParams,
|
||||
): Promise<PendingOrderUpdateB2bPackingItemsResponse> {
|
||||
return request({
|
||||
url: "/system",
|
||||
method: "post",
|
||||
params: {
|
||||
method: "order.updateB2bPackingItems",
|
||||
v,
|
||||
timestamp: Date.now(),
|
||||
},
|
||||
data,
|
||||
isSystemApi: true,
|
||||
} as any);
|
||||
}
|
||||
|
||||
export function orderPendingOrderReverseReviewOrder(
|
||||
data: PendingOrderReverseReviewParams,
|
||||
): Promise<any> {
|
||||
@ -1197,6 +1497,10 @@ export type OrderPendingOrderApi = {
|
||||
cancelB2b: typeof orderPendingOrderCancelB2b;
|
||||
setB2bUrgent: typeof orderPendingOrderSetB2bUrgent;
|
||||
cancelB2bUrgent: typeof orderPendingOrderCancelB2bUrgent;
|
||||
setB2bPickupPlate: typeof orderPendingOrderSetB2bPickupPlate;
|
||||
getB2bPackingSnapshot: typeof orderPendingOrderGetB2bPackingSnapshot;
|
||||
updateB2bPackingItems: typeof orderPendingOrderUpdateB2bPackingItems;
|
||||
updateB2bOrderImages: typeof orderPendingOrderUpdateB2bOrderImages;
|
||||
startB2bPrep: typeof orderPendingOrderStartB2bPrep;
|
||||
cancelB2bPrep: typeof orderPendingOrderCancelB2bPrep;
|
||||
finishB2bPrep: typeof orderPendingOrderFinishB2bPrep;
|
||||
@ -1241,6 +1545,10 @@ export const orderPendingOrder: OrderPendingOrderApi = {
|
||||
cancelB2b: orderPendingOrderCancelB2b,
|
||||
setB2bUrgent: orderPendingOrderSetB2bUrgent,
|
||||
cancelB2bUrgent: orderPendingOrderCancelB2bUrgent,
|
||||
setB2bPickupPlate: orderPendingOrderSetB2bPickupPlate,
|
||||
getB2bPackingSnapshot: orderPendingOrderGetB2bPackingSnapshot,
|
||||
updateB2bPackingItems: orderPendingOrderUpdateB2bPackingItems,
|
||||
updateB2bOrderImages: orderPendingOrderUpdateB2bOrderImages,
|
||||
startB2bPrep: orderPendingOrderStartB2bPrep,
|
||||
cancelB2bPrep: orderPendingOrderCancelB2bPrep,
|
||||
finishB2bPrep: orderPendingOrderFinishB2bPrep,
|
||||
@ -1283,6 +1591,10 @@ export const orderPendingOrder2b = {
|
||||
list: orderPendingOrder2bList,
|
||||
setB2bUrgent: orderPendingOrderSetB2bUrgent,
|
||||
cancelB2bUrgent: orderPendingOrderCancelB2bUrgent,
|
||||
setB2bPickupPlate: orderPendingOrderSetB2bPickupPlate,
|
||||
getB2bPackingSnapshot: orderPendingOrderGetB2bPackingSnapshot,
|
||||
updateB2bPackingItems: orderPendingOrderUpdateB2bPackingItems,
|
||||
updateB2bOrderImages: orderPendingOrderUpdateB2bOrderImages,
|
||||
startB2bPrep: orderPendingOrderStartB2bPrep,
|
||||
cancelB2bPrep: orderPendingOrderCancelB2bPrep,
|
||||
finishB2bPrep: orderPendingOrderFinishB2bPrep,
|
||||
|
||||
@ -2,6 +2,39 @@ import request from '@/utils/request'
|
||||
|
||||
const v = '1.0'
|
||||
|
||||
/**
|
||||
* order.pendingOrder.detail / order.deliveryOrder.detail 响应 data.b2b
|
||||
* 仅 is_b2b='Y' 的订单输出;非 B2B 为 null,副表无作业行时为占位对象(数值 0 / is_*='N' / 时间为 null)
|
||||
*/
|
||||
export type OrderDetailB2bInfo = {
|
||||
total_box_count?: number
|
||||
pickup_plate_number?: string | null
|
||||
prep_remark?: string | null
|
||||
prep_duration_seconds?: number | null
|
||||
/** none=未开始 / padding=备货中 / fin=已完成 */
|
||||
prep_status?: string
|
||||
prep_operator_id?: number | null
|
||||
prep_operator_name?: string | null
|
||||
prep_start_at?: string | null
|
||||
/** Y=加急 N=普通 */
|
||||
is_urgent?: string
|
||||
/** Y=已提货 N=未提货 */
|
||||
is_picked_up?: string
|
||||
picked_up_at?: string | null
|
||||
/** 作业明细创建时间(与订单 create_at 不同) */
|
||||
created_at?: string | null
|
||||
/** 备货完成时间 */
|
||||
prep_at?: string | null
|
||||
}
|
||||
|
||||
/** 订单详情响应 data.images / data.pickup_images(B2B 留证照片,元素 { id: file_id, url, display_order }) */
|
||||
export type OrderDetailImage = {
|
||||
/** file_id */
|
||||
id: number | string
|
||||
url: string
|
||||
display_order?: number
|
||||
}
|
||||
|
||||
/** order.wave.batchList 的 where 白名单(禁止 warehouse_id / warehouseId) */
|
||||
export type WaveBatchListWhere = {
|
||||
wave_id?: number | string
|
||||
|
||||
@ -129,7 +129,7 @@ import { Plus, Camera, CameraFilled, Picture } from '@element-plus/icons-vue'
|
||||
import * as indexApi from '@/api/index/index'
|
||||
import SparkMD5 from 'spark-md5'
|
||||
import { useUserStore } from '@/stores/modules/user'
|
||||
import { resolveUploadUrl } from '@/utils/cosImageUpload'
|
||||
import { resolveUploadUrl, unwrapFileInfo } from '@/utils/cosImageUpload'
|
||||
|
||||
const props = defineProps<{
|
||||
type: string
|
||||
@ -336,8 +336,9 @@ const uploadFile = async (file: any) => {
|
||||
throw new Error(`上传失败: ${response.status}`)
|
||||
}
|
||||
|
||||
// 通知后端登记文件,响应 data 里带回图片 URL(兼容 { data: { code, data: { fileUrl } } } 双层包裹)
|
||||
const { data: resultData } = await indexApi.uploadSuccessNotify(cosConfig.fileInfo || cosConfig)
|
||||
return resultData
|
||||
return unwrapFileInfo(resultData)
|
||||
}
|
||||
|
||||
const getCOSUploadConfig = async (file: File) => {
|
||||
|
||||
@ -784,9 +784,11 @@ const displayColumns = computed(() => {
|
||||
.map((column) => {
|
||||
const cfg = configMap[String(column.prop || '')]
|
||||
if (!cfg) return column
|
||||
// 操作列宽度由页面定义决定:历史保存的列宽可能偏窄,会把行内按钮裁掉
|
||||
const isActionColumn = String(column.prop || '') === 'actions'
|
||||
return {
|
||||
...column,
|
||||
width: cfg.width ?? column.width,
|
||||
width: isActionColumn ? column.width : (cfg.width ?? column.width),
|
||||
fixed: cfg.fixed === false ? undefined : (cfg.fixed ?? column.fixed)
|
||||
}
|
||||
})
|
||||
|
||||
@ -130,14 +130,77 @@ function pickFileUrl(src: Record<string, unknown>): string {
|
||||
return value ? String(value) : ''
|
||||
}
|
||||
|
||||
/** 兼容 fileId / file_id / file.id */
|
||||
/** 兼容 fileId / file_id / file.id / file.file_id */
|
||||
function pickFileId(src: Record<string, unknown>): number | string | undefined {
|
||||
const nested = src.file as Record<string, unknown> | undefined
|
||||
const value = src.fileId ?? src.file_id ?? nested?.id
|
||||
const value = src.fileId ?? src.file_id ?? nested?.id ?? nested?.file_id
|
||||
if (value === null || value === undefined || value === '') return undefined
|
||||
return value as number | string
|
||||
}
|
||||
|
||||
/** 是否像「文件信息」对象(用于逐层解包) */
|
||||
function looksLikeFileInfo(src: Record<string, unknown>) {
|
||||
return (
|
||||
pickFileUrl(src) !== '' ||
|
||||
pickFileId(src) !== undefined ||
|
||||
'fileName' in src ||
|
||||
'file_name' in src ||
|
||||
'fileKey' in src ||
|
||||
'file_key' in src
|
||||
)
|
||||
}
|
||||
|
||||
/**
|
||||
* 逐层解包后端返回,取出真正的文件信息对象。兼容:
|
||||
* - `{ fileId, fileUrl, ... }`
|
||||
* - `{ data: { fileId, fileUrl, ... } }`(request 拦截器解一层)
|
||||
* - `{ data: { code, message, data: { fileId, fileUrl, ... } } }`(后端中间件再包一层)
|
||||
*/
|
||||
export function unwrapFileInfo(src: unknown): Record<string, unknown> {
|
||||
let current: unknown = src
|
||||
for (let depth = 0; depth < 4; depth += 1) {
|
||||
if (!current || typeof current !== 'object') break
|
||||
const record = current as Record<string, unknown>
|
||||
if (looksLikeFileInfo(record)) return record
|
||||
const next = record.data
|
||||
if (!next || typeof next !== 'object') return record
|
||||
current = next
|
||||
}
|
||||
return (current && typeof current === 'object' ? current : {}) as Record<string, unknown>
|
||||
}
|
||||
|
||||
/** COS 直传配置判定(避免把配置里的 data 表单字段误当成外层包裹) */
|
||||
function looksLikeCosConfig(src: Record<string, unknown>) {
|
||||
return [
|
||||
'uploadUrl',
|
||||
'upload_url',
|
||||
'isNew',
|
||||
'fileInfo',
|
||||
'file_info',
|
||||
'error',
|
||||
'headers',
|
||||
'fileUrl',
|
||||
'file_url',
|
||||
'fileId',
|
||||
'file_id'
|
||||
].some((key) => key in src)
|
||||
}
|
||||
|
||||
/** 解包 `index.getCOSUploadConfig` 返回(兼容双层 data 包裹) */
|
||||
function resolveCosConfig(res: unknown): CosUploadConfig {
|
||||
const record = (res && typeof res === 'object' ? res : {}) as Record<string, unknown>
|
||||
const candidate = ((record.data as Record<string, unknown> | undefined) ?? record) as Record<
|
||||
string,
|
||||
unknown
|
||||
>
|
||||
if (looksLikeCosConfig(candidate)) return candidate as CosUploadConfig
|
||||
const nested = candidate.data
|
||||
if (nested && typeof nested === 'object' && looksLikeCosConfig(nested as Record<string, unknown>)) {
|
||||
return nested as CosUploadConfig
|
||||
}
|
||||
return candidate as CosUploadConfig
|
||||
}
|
||||
|
||||
/**
|
||||
* 上传图片并返回图片地址
|
||||
* @param file 待上传的图片文件
|
||||
@ -149,7 +212,7 @@ export async function uploadImageToCos(
|
||||
): Promise<CosUploadedFile> {
|
||||
const md5 = await calculateFileMd5(file).catch(() => '')
|
||||
|
||||
const configRes: any = await getCOSUploadConfig({
|
||||
const configRes: unknown = await getCOSUploadConfig({
|
||||
fileName: file.name,
|
||||
fileType: file.type,
|
||||
fileSize: file.size,
|
||||
@ -158,7 +221,7 @@ export async function uploadImageToCos(
|
||||
...(ctx?.id !== undefined && ctx?.id !== null && ctx?.id !== '' ? { id: ctx.id } : {})
|
||||
})
|
||||
|
||||
const config = ((configRes?.data ?? configRes ?? {}) as CosUploadConfig) || {}
|
||||
const config = resolveCosConfig(configRes) || {}
|
||||
if (config.error) throw new Error(config.msg || '获取上传配置失败')
|
||||
|
||||
// 同 MD5 文件已存在:无需重复上传,直接用已有文件信息
|
||||
@ -193,9 +256,9 @@ export async function uploadImageToCos(
|
||||
}
|
||||
if (!uploadRes.ok) throw new Error(`上传失败:${uploadRes.status}`)
|
||||
|
||||
// 通知后端登记文件,响应 data 里带回图片 URL(fileUrl/file_url)
|
||||
const notifyRes: any = await uploadSuccessNotify(config.fileInfo || config)
|
||||
const info = ((notifyRes?.data ?? notifyRes ?? {}) as Record<string, unknown>) || {}
|
||||
// 通知后端登记文件;响应可能是 { data: { code, message, data: { fileUrl } } } 的双层包裹
|
||||
const notifyRes: unknown = await uploadSuccessNotify(config.fileInfo || config)
|
||||
const info = unwrapFileInfo(notifyRes)
|
||||
const fileUrl = pickFileUrl(info)
|
||||
if (!fileUrl) throw new Error('上传成功但未返回图片地址')
|
||||
return { fileUrl, fileId: pickFileId(info), raw: info }
|
||||
|
||||
@ -11,7 +11,22 @@
|
||||
:label="field.label"
|
||||
:span="field.span"
|
||||
>
|
||||
<span v-if="field.tagClass" :class="field.tagClass">{{ field.text }}</span>
|
||||
<template v-if="field.images">
|
||||
<div v-if="field.images.length" class="field-images">
|
||||
<el-image
|
||||
v-for="(url, index) in field.images"
|
||||
:key="`${url}-${index}`"
|
||||
class="detail-image"
|
||||
:src="url"
|
||||
:preview-src-list="field.images"
|
||||
:initial-index="index"
|
||||
preview-teleported
|
||||
fit="cover"
|
||||
/>
|
||||
</div>
|
||||
<span v-else>-</span>
|
||||
</template>
|
||||
<span v-else-if="field.tagClass" :class="field.tagClass">{{ field.text }}</span>
|
||||
<div v-else-if="field.multiline" class="field-multiline" :title="field.text">
|
||||
{{ field.text }}
|
||||
</div>
|
||||
@ -34,6 +49,7 @@ import {
|
||||
ORDER_DETAIL_TIME_FIELDS,
|
||||
COMMON_TRANSLATIONS,
|
||||
formatOrderTime,
|
||||
getOrderDetailFieldValue,
|
||||
getTagType,
|
||||
getStatusTextClass,
|
||||
orderDetailCompactSections,
|
||||
@ -128,7 +144,14 @@ function getFieldRawValue(prop: string) {
|
||||
if (prop === 'recheck_status') {
|
||||
return resolveOrderRecheckStatus(detail.value)
|
||||
}
|
||||
return detail.value[prop]
|
||||
// 支持 b2b.prep_status 这类嵌套路径(B2B 作业明细在响应 data 里是独立对象)
|
||||
return getOrderDetailFieldValue(detail.value, prop)
|
||||
}
|
||||
|
||||
/** 字段是否走翻译表:嵌套字段(b2b.prep_status)按最后一段取名 */
|
||||
function fieldTranslateKey(prop: string) {
|
||||
const index = prop.lastIndexOf('.')
|
||||
return index >= 0 ? prop.slice(index + 1) : prop
|
||||
}
|
||||
|
||||
function displayFieldValue(field: OrderDetailFieldConfig) {
|
||||
@ -157,23 +180,37 @@ function displayFieldValue(field: OrderDetailFieldConfig) {
|
||||
return formatOrderTime(raw)
|
||||
}
|
||||
|
||||
const translateKey = fieldTranslateKey(field.prop)
|
||||
if (field.tag) {
|
||||
return translateOrderField(field.prop, raw)
|
||||
return translateOrderField(translateKey, raw)
|
||||
}
|
||||
|
||||
if (COMMON_TRANSLATIONS[field.prop]) {
|
||||
return translateOrderField(field.prop, raw)
|
||||
if (COMMON_TRANSLATIONS[translateKey]) {
|
||||
return translateOrderField(translateKey, raw)
|
||||
}
|
||||
|
||||
return raw
|
||||
}
|
||||
|
||||
/** 图片字段取值:兼容字符串数组与 { url } 对象数组 */
|
||||
function toDetailImageUrls(value: unknown): string[] {
|
||||
if (!Array.isArray(value)) return []
|
||||
return value
|
||||
.map((item) =>
|
||||
typeof item === 'string' ? item : String((item as Record<string, unknown> | null)?.url ?? '')
|
||||
)
|
||||
.map((url) => url.trim())
|
||||
.filter(Boolean)
|
||||
}
|
||||
|
||||
type DetailFieldView = {
|
||||
prop: string
|
||||
label: string
|
||||
span: number
|
||||
multiline: boolean
|
||||
text: string
|
||||
hasValue: boolean
|
||||
images?: string[]
|
||||
tagClass?: string
|
||||
}
|
||||
|
||||
@ -190,20 +227,40 @@ type DetailSectionView = {
|
||||
*/
|
||||
const sectionViews = computed<DetailSectionView[]>(() => {
|
||||
if (!detail.value) return []
|
||||
return activeSections.value.map((section) => ({
|
||||
title: section.title,
|
||||
column: section.column || 3,
|
||||
fields: section.fields.map((field) => ({
|
||||
prop: field.prop,
|
||||
label: field.label,
|
||||
span: field.span || 1,
|
||||
multiline: !!field.multiline,
|
||||
text: String(displayFieldValue(field) ?? ''),
|
||||
tagClass: field.tag
|
||||
? getStatusTextClass(getTagType(field.prop, getFieldRawValue(field.prop)))
|
||||
: undefined
|
||||
return activeSections.value
|
||||
.map((section) => ({
|
||||
title: section.title,
|
||||
column: section.column || 3,
|
||||
optional: !!section.optional,
|
||||
fields: section.fields.map((field): DetailFieldView => {
|
||||
if (field.images) {
|
||||
const images = toDetailImageUrls(getFieldRawValue(field.prop))
|
||||
return {
|
||||
prop: field.prop,
|
||||
label: field.label,
|
||||
span: field.span || 1,
|
||||
multiline: false,
|
||||
text: '',
|
||||
hasValue: images.length > 0,
|
||||
images
|
||||
}
|
||||
}
|
||||
const text = String(displayFieldValue(field) ?? '')
|
||||
return {
|
||||
prop: field.prop,
|
||||
label: field.label,
|
||||
span: field.span || 1,
|
||||
multiline: !!field.multiline,
|
||||
text,
|
||||
hasValue: text !== '' && text !== '-',
|
||||
tagClass: field.tag
|
||||
? getStatusTextClass(getTagType(fieldTranslateKey(field.prop), getFieldRawValue(field.prop)))
|
||||
: undefined
|
||||
}
|
||||
})
|
||||
}))
|
||||
}))
|
||||
.filter((section) => !section.optional || section.fields.some((field) => field.hasValue))
|
||||
.map((section) => ({ title: section.title, column: section.column, fields: section.fields }))
|
||||
})
|
||||
|
||||
function normalizeDetailPayload(payload: Record<string, any>) {
|
||||
@ -221,7 +278,19 @@ function normalizeDetailPayload(payload: Record<string, any>) {
|
||||
return {
|
||||
...orderDetail,
|
||||
recheck_status: resolveOrderRecheckStatus(orderDetail),
|
||||
waybill_codes: waybillCodes
|
||||
waybill_codes: waybillCodes,
|
||||
// B2B 专属字段在响应 data 顶层(与 detail 同级):b2b 作业明细 + 备货照片 images + 提货照片 pickup_images
|
||||
b2b: payload.b2b ?? orderDetail.b2b ?? null,
|
||||
images: Array.isArray(payload.images)
|
||||
? payload.images
|
||||
: Array.isArray(orderDetail.images)
|
||||
? orderDetail.images
|
||||
: [],
|
||||
pickup_images: Array.isArray(payload.pickup_images)
|
||||
? payload.pickup_images
|
||||
: Array.isArray(orderDetail.pickup_images)
|
||||
? orderDetail.pickup_images
|
||||
: []
|
||||
}
|
||||
}
|
||||
|
||||
@ -340,6 +409,20 @@ onBeforeUnmount(() => {
|
||||
overflow: auto;
|
||||
}
|
||||
|
||||
.field-images {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
gap: 6px;
|
||||
}
|
||||
|
||||
.detail-image {
|
||||
width: 56px;
|
||||
height: 56px;
|
||||
border-radius: 4px;
|
||||
border: 1px solid #ebeef5;
|
||||
cursor: zoom-in;
|
||||
}
|
||||
|
||||
.empty-tip {
|
||||
height: 100%;
|
||||
display: flex;
|
||||
|
||||
@ -47,6 +47,20 @@ export const COMMON_TRANSLATIONS: Record<string, Record<string, string>> = {
|
||||
'Y': '是',
|
||||
'N': '否'
|
||||
},
|
||||
/** B2B 作业明细(订单详情 data.b2b):是否加急 / 是否提货 / 备货状态 */
|
||||
is_urgent: {
|
||||
'Y': '加急',
|
||||
'N': '普通'
|
||||
},
|
||||
is_picked_up: {
|
||||
'Y': '是',
|
||||
'N': '否'
|
||||
},
|
||||
prep_status: {
|
||||
'none': '未开始',
|
||||
'padding': '备货中',
|
||||
'fin': '已完成'
|
||||
},
|
||||
status: {
|
||||
'pedding': '待审核',
|
||||
'created': '已创建',
|
||||
@ -213,6 +227,20 @@ export const COMMON_TAG_TYPES: Record<string, Record<string, string>> = {
|
||||
'Y': 'danger',
|
||||
'N': 'info'
|
||||
},
|
||||
/** B2B 作业明细(订单详情 data.b2b)标签色 */
|
||||
is_urgent: {
|
||||
'Y': 'danger',
|
||||
'N': 'info'
|
||||
},
|
||||
is_picked_up: {
|
||||
'Y': 'success',
|
||||
'N': 'info'
|
||||
},
|
||||
prep_status: {
|
||||
'none': 'info',
|
||||
'padding': 'warning',
|
||||
'fin': 'success'
|
||||
},
|
||||
status: {
|
||||
'pedding': 'warning',
|
||||
'pending': 'warning',
|
||||
@ -574,16 +602,6 @@ export const ORDER_TOOLBAR_BUTTONS: Record<string, ToolbarButtonConfig> = {
|
||||
disabledKey: 'hasNoSelection',
|
||||
action: 'openCancelB2bDialog'
|
||||
},
|
||||
/** B2B 备货开始(order.startB2bPrep):单订单作业,必须恰好勾选 1 行 */
|
||||
b2bStartPrep: {
|
||||
key: 'b2bStartPrep',
|
||||
label: '开始备货',
|
||||
size: 'small',
|
||||
category: 'action',
|
||||
loadingKey: 'b2bActionLoading',
|
||||
disabledKey: 'notSingleSelection',
|
||||
action: 'handleB2bStartPrep'
|
||||
},
|
||||
/** B2B 备货完成(order.finishB2bPrep):必填备货备注 + 总箱数,完成时同步扣减库存 */
|
||||
b2bFinishPrep: {
|
||||
key: 'b2bFinishPrep',
|
||||
@ -1017,14 +1035,70 @@ export type OrderDetailFieldConfig = {
|
||||
time?: boolean
|
||||
waybill?: boolean
|
||||
multiline?: boolean
|
||||
/** 图片字段:值按 URL 列表渲染(兼容 { url } 对象数组) */
|
||||
images?: boolean
|
||||
}
|
||||
|
||||
export type OrderDetailSectionConfig = {
|
||||
title: string
|
||||
column?: number
|
||||
fields: OrderDetailFieldConfig[]
|
||||
/** 分区内所有字段都无值时整体隐藏(用于仅部分订单才有的字段,如 B2B 作业明细/照片) */
|
||||
optional?: boolean
|
||||
}
|
||||
|
||||
/** 订单详情字段取值:支持 `b2b.prep_status` 这类嵌套路径 */
|
||||
export function getOrderDetailFieldValue(
|
||||
row: Record<string, any> | null | undefined,
|
||||
prop: string
|
||||
): unknown {
|
||||
if (!row || typeof row !== 'object') return undefined
|
||||
if (!prop.includes('.')) return row[prop]
|
||||
let current: any = row
|
||||
for (const key of prop.split('.')) {
|
||||
if (current === null || current === undefined || typeof current !== 'object') return undefined
|
||||
current = current[key]
|
||||
}
|
||||
return current
|
||||
}
|
||||
|
||||
/**
|
||||
* B2B 专属详情分区(order.pendingOrder.detail / order.deliveryOrder.detail 的 data.b2b、data.images、data.pickup_images)
|
||||
* 仅 is_b2b='Y' 的订单才有值;非 B2B 订单 b2b 为 null、images / pickup_images 为空数组,分区由 optional 自动隐藏。
|
||||
*/
|
||||
const b2bOrderDetailSections: OrderDetailSectionConfig[] = [
|
||||
{
|
||||
title: 'B2B作业',
|
||||
column: 3,
|
||||
optional: true,
|
||||
fields: [
|
||||
{ prop: 'b2b.prep_status', label: '备货状态', tag: true },
|
||||
{ prop: 'b2b.is_urgent', label: '是否加急', tag: true },
|
||||
{ prop: 'b2b.is_picked_up', label: '是否提货', tag: true },
|
||||
{ prop: 'b2b.total_box_count', label: '总箱数' },
|
||||
{ prop: 'b2b.pickup_plate_number', label: '提货车牌' },
|
||||
{ prop: 'b2b.prep_operator_name', label: '备货人' },
|
||||
{ prop: 'b2b.prep_duration_seconds', label: '备货时长(秒)' },
|
||||
{ prop: 'b2b.prep_start_at', label: '备货开始时间', time: true },
|
||||
{ prop: 'b2b.prep_at', label: '备货时间', time: true },
|
||||
{ prop: 'b2b.picked_up_at', label: '提货时间', time: true },
|
||||
{ prop: 'b2b.prep_remark', label: '备货备注', span: 3, multiline: true }
|
||||
]
|
||||
},
|
||||
{
|
||||
title: '备货照片',
|
||||
column: 1,
|
||||
optional: true,
|
||||
fields: [{ prop: 'images', label: '备货照片', images: true }]
|
||||
},
|
||||
{
|
||||
title: '提货照片',
|
||||
column: 1,
|
||||
optional: true,
|
||||
fields: [{ prop: 'pickup_images', label: '提货照片', images: true }]
|
||||
}
|
||||
]
|
||||
|
||||
/** 订单明细显示全部:对齐 order.pendingOrder.detail data.detail 字段 */
|
||||
export const orderDetailFullSections: OrderDetailSectionConfig[] = [
|
||||
{
|
||||
@ -1095,6 +1169,7 @@ export const orderDetailFullSections: OrderDetailSectionConfig[] = [
|
||||
{ prop: 'basket_number', label: '篮号' }
|
||||
]
|
||||
},
|
||||
...b2bOrderDetailSections,
|
||||
{
|
||||
title: '收货与物流',
|
||||
column: 3,
|
||||
@ -1198,6 +1273,7 @@ export const orderDetailCompactSections: OrderDetailSectionConfig[] = [
|
||||
{ prop: 'lock_status', label: '锁定状态', tag: true }
|
||||
]
|
||||
},
|
||||
...b2bOrderDetailSections,
|
||||
{
|
||||
title: '收货与物流',
|
||||
column: 3,
|
||||
@ -1845,6 +1921,9 @@ export const b2bPrepDurationScanField = scanBasicField({
|
||||
defaultOperator: 'ge'
|
||||
})
|
||||
|
||||
/** ScanBox:B2B 作业明细创建时间(wms_order_b2b.created_at,与订单 create_at 不同) */
|
||||
export const b2bCreatedAtRangeScanField = scanBasicField({ label: '作业创建时间', value: 'created_at', type: 'datetimerange' })
|
||||
|
||||
/** B2B 页签共用的作业筛选项(追加到普通筛选项之后) */
|
||||
const b2bExtraScanFields = [
|
||||
{ ...b2bUrgentScanField, group: SCAN_B2B_GROUP },
|
||||
@ -1857,7 +1936,8 @@ const b2bExtraScanFields = [
|
||||
{ ...b2bPickupPlateScanField, group: SCAN_B2B_GROUP },
|
||||
{ ...b2bPrepRemarkScanField, group: SCAN_B2B_GROUP },
|
||||
{ ...b2bTotalBoxCountScanField, group: SCAN_B2B_GROUP },
|
||||
{ ...b2bPrepDurationScanField, group: SCAN_B2B_GROUP }
|
||||
{ ...b2bPrepDurationScanField, group: SCAN_B2B_GROUP },
|
||||
{ ...b2bCreatedAtRangeScanField, group: SCAN_B2B_GROUP }
|
||||
]
|
||||
|
||||
// deliveryOrder相关配置
|
||||
@ -2390,6 +2470,12 @@ export const ORDER_LIST_FIELD_LABELS: Record<string, string> = {
|
||||
prep_at: '备货时间',
|
||||
is_picked_up: '是否提货',
|
||||
picked_up_at: '提货时间',
|
||||
created_at: '作业创建时间',
|
||||
images: '备货照片',
|
||||
pickup_images: '提货照片',
|
||||
prep_status: '备货状态',
|
||||
prep_operator_name: '备货人',
|
||||
prep_start_at: '备货开始时间',
|
||||
}
|
||||
|
||||
export function applyOrderListColumnLabels<T extends { prop: string; label: string }>(columns: T[]): T[] {
|
||||
@ -2467,6 +2553,12 @@ export function buildPendingB2bColumns() {
|
||||
{ prop: 'prep_at', label: '备货时间', width: '165', formatter: orderTimeFormatter },
|
||||
{ prop: 'is_picked_up', label: '是否提货', width: '90', formatter: (row: any) => (String(row?.is_picked_up ?? '').trim().toUpperCase() === 'Y' ? '是' : '否') },
|
||||
{ prop: 'picked_up_at', label: '提货时间', width: '165', formatter: orderTimeFormatter },
|
||||
// order.pendingOrder2b.list 新增:作业明细创建时间 / 备货与提货照片
|
||||
{ prop: 'created_at', label: '作业创建时间', width: '165', formatter: orderTimeFormatter },
|
||||
{ prop: 'images', label: '备货照片', width: '110', imgs: (row: any) => toB2bImageUrls(row?.images) },
|
||||
{ prop: 'pickup_images', label: '提货照片', width: '110', imgs: (row: any) => toB2bImageUrls(row?.pickup_images) },
|
||||
// 行内操作列(按状态动态:备货 / 确认提货 / 设置车牌)
|
||||
{ prop: 'actions', label: '操作', width: '220', minWidth: '220', fixed: 'right' },
|
||||
]
|
||||
return applyOrderListCopyActions([...base, ...extras])
|
||||
}
|
||||
@ -2479,6 +2571,67 @@ export function translateB2bPrepStatus(value: unknown): string {
|
||||
return '未开始'
|
||||
}
|
||||
|
||||
/** B2B 行内操作项(表格「操作」列按订单状态动态生成) */
|
||||
export type B2bRowAction = {
|
||||
key: 'prep' | 'pickup' | 'plate'
|
||||
label: string
|
||||
}
|
||||
|
||||
/**
|
||||
* B2B 列表行内操作(操作列):
|
||||
* - 备货:未提货且备货未完成(padding 显示「继续备货」,none 显示「开始备货」);分箱在备货窗口内完成
|
||||
* - 确认提货:备货已完成且未提货
|
||||
* - 设置车牌:提货前均可维护(提货后车牌随提货锁定)
|
||||
* 已取消订单不展示任何操作。
|
||||
*/
|
||||
export function buildB2bRowActions(row: Record<string, any> | null | undefined): B2bRowAction[] {
|
||||
if (!row) return []
|
||||
if (String(row?.status ?? '').trim().toLowerCase() === 'cancel') return []
|
||||
|
||||
const pickedUp = String(row?.is_picked_up ?? '').trim().toUpperCase() === 'Y'
|
||||
const prepStatus = String(row?.prep_status ?? '').trim().toLowerCase()
|
||||
const actions: B2bRowAction[] = []
|
||||
|
||||
if (!pickedUp && prepStatus !== 'fin') {
|
||||
actions.push({ key: 'prep', label: prepStatus === 'padding' ? '继续备货' : '开始备货' })
|
||||
}
|
||||
if (!pickedUp && prepStatus === 'fin') {
|
||||
actions.push({ key: 'pickup', label: '确认提货' })
|
||||
}
|
||||
if (!pickedUp) {
|
||||
actions.push({ key: 'plate', label: '设置车牌' })
|
||||
}
|
||||
return actions
|
||||
}
|
||||
|
||||
/**
|
||||
* B2B 分箱快照:逐商品取货储位文案(order.getB2bPackingSnapshot 的 items[].pick_locations)
|
||||
* 元素 { space_id, space_name, quantity },展示为「库位名×数量」
|
||||
*/
|
||||
export function formatB2bItemPickLocations(item: Record<string, any> | null | undefined): string {
|
||||
const list = Array.isArray(item?.pick_locations) ? item.pick_locations : []
|
||||
const texts = list
|
||||
.map((row: any) => {
|
||||
const name = String(row?.space_name ?? row?.space_id ?? '').trim()
|
||||
const qty = Number(row?.quantity ?? 0)
|
||||
if (!name) return ''
|
||||
return Number.isFinite(qty) && qty > 0 ? `${name}×${qty}` : name
|
||||
})
|
||||
.filter((text: string) => !!text)
|
||||
return texts.length ? texts.join(',') : '--'
|
||||
}
|
||||
|
||||
/** B2B 列表:照片字段(images / pickup_images)→ URL 列表,供 UpperTable 的 imgs 列渲染 */
|
||||
export function toB2bImageUrls(value: unknown): string[] {
|
||||
if (!Array.isArray(value)) return []
|
||||
return value
|
||||
.map((item) =>
|
||||
typeof item === 'string' ? item : String((item as Record<string, any> | null)?.url ?? '')
|
||||
)
|
||||
.map((url) => url.trim())
|
||||
.filter(Boolean)
|
||||
}
|
||||
|
||||
/**
|
||||
* 配送 B2B 订单专属列(仅「配送B2B订单」页签使用)。
|
||||
* order.deliveryOrder2b.list 在配送订单列基础上额外带出 wms_order_b2b 作业字段。
|
||||
@ -2498,6 +2651,12 @@ export function buildDeliveryB2bColumns() {
|
||||
{ prop: 'prep_at', label: '备货时间', width: '165', formatter: orderTimeFormatter },
|
||||
{ prop: 'is_picked_up', label: '是否提货', width: '90', formatter: (row: any) => (String(row?.is_picked_up ?? '').trim().toUpperCase() === 'Y' ? '是' : '否') },
|
||||
{ prop: 'picked_up_at', label: '提货时间', width: '165', formatter: orderTimeFormatter },
|
||||
// order.deliveryOrder2b.list 新增:作业明细创建时间 / 备货与提货照片
|
||||
{ prop: 'created_at', label: '作业创建时间', width: '165', formatter: orderTimeFormatter },
|
||||
{ prop: 'images', label: '备货照片', width: '110', imgs: (row: any) => toB2bImageUrls(row?.images) },
|
||||
{ prop: 'pickup_images', label: '提货照片', width: '110', imgs: (row: any) => toB2bImageUrls(row?.pickup_images) },
|
||||
// 行内操作列(按状态动态:备货 / 确认提货 / 设置车牌)
|
||||
{ prop: 'actions', label: '操作', width: '220', minWidth: '220', fixed: 'right' },
|
||||
]
|
||||
return applyOrderListCopyActions([...base, ...extras])
|
||||
}
|
||||
@ -2647,11 +2806,11 @@ export const pendingToolbarButtonKeys = [
|
||||
export const pendingToolbarButtons = pickToolbarButtons(pendingToolbarButtonKeys)
|
||||
|
||||
/**
|
||||
* B2B 作业按钮(order.startB2bPrep / finishB2bPrep / cancelB2bPrep / pickupB2b / setB2bUrgent / cancelB2bUrgent)
|
||||
* B2B 作业按钮(order.finishB2bPrep / cancelB2bPrep / pickupB2b / setB2bUrgent / cancelB2bUrgent)
|
||||
* 仅追加到「待处理B2B订单」「配送B2B订单」两个页签,普通订单页不展示。
|
||||
* 「开始备货 / 分箱 / 设置车牌」是单订单行内操作,放在表格「操作」列。
|
||||
*/
|
||||
export const b2bToolbarButtonKeys = [
|
||||
'b2bStartPrep',
|
||||
'b2bFinishPrep',
|
||||
'b2bCancelPrep',
|
||||
'b2bPickup',
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
<template>
|
||||
<template>
|
||||
<div class="order-sub-container">
|
||||
<scan-box
|
||||
ref="scanBox"
|
||||
@ -152,6 +152,22 @@
|
||||
<span v-else style="color:#909399">—</span>
|
||||
</template>
|
||||
|
||||
<!-- B2B 行内操作(按状态动态):备货(窗口内完成分箱)/ 确认提货 / 设置车牌 -->
|
||||
<template #column-actions="{ row }">
|
||||
<div class="b2b-row-actions">
|
||||
<el-button
|
||||
v-for="action in buildB2bRowActions(row)"
|
||||
:key="action.key"
|
||||
link
|
||||
type="primary"
|
||||
size="small"
|
||||
@click.stop="handleB2bRowAction(action.key, row)"
|
||||
>
|
||||
{{ action.label }}
|
||||
</el-button>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<template #empty>
|
||||
<div class="empty-tip">暂无配送订单</div>
|
||||
</template>
|
||||
@ -333,6 +349,22 @@
|
||||
@success="handleTransferByOrdersSuccess"
|
||||
/>
|
||||
|
||||
<!-- B2B 备货作业窗口(行内「开始备货」):打开即 startB2bPrep,内含分箱登记 + 备货完成 -->
|
||||
<b2b-prep-form
|
||||
v-if="b2b && prepDialogVisible"
|
||||
:visible="prepDialogVisible"
|
||||
:starting="prepStarting"
|
||||
:submitting="b2bActionLoading"
|
||||
:snapshot-loading="prepSnapshotLoading"
|
||||
:row="prepRow"
|
||||
:info="prepInfo"
|
||||
:snapshot="prepSnapshot"
|
||||
:save-request="savePrepPackingQuiet"
|
||||
@update:visible="handlePrepDialogVisibleChange"
|
||||
@save-packing="savePrepPacking"
|
||||
@submit-finish="submitPrepFinish"
|
||||
/>
|
||||
|
||||
<!-- B2B 备货完成(order.finishB2bPrep):仅「配送B2B订单」页签可用 -->
|
||||
<b2b-prep-finish-form
|
||||
v-if="b2b && finishPrepDialogVisible"
|
||||
@ -342,6 +374,24 @@
|
||||
@submit="submitFinishPrep"
|
||||
/>
|
||||
|
||||
<!-- B2B 提货车牌(order.setB2bPickupPlate):行内「设置」打开,留空保存表示清空 -->
|
||||
<b2b-pickup-plate-form
|
||||
v-if="b2b && pickupPlateDialogVisible"
|
||||
v-model:visible="pickupPlateDialogVisible"
|
||||
:loading="b2bActionLoading"
|
||||
:row="pickupPlateRow"
|
||||
@submit="submitPickupPlate"
|
||||
/>
|
||||
|
||||
<!-- B2B 确认提货(order.pickupB2b):车牌 + 提货照片随提货一次提交 -->
|
||||
<b2b-pickup-form
|
||||
v-if="b2b && pickupDialogVisible"
|
||||
v-model:visible="pickupDialogVisible"
|
||||
:loading="b2bActionLoading"
|
||||
:row="pickupRow"
|
||||
@submit="submitPickup"
|
||||
/>
|
||||
|
||||
<order-export-columns-dialog
|
||||
v-if="exportColumnsDialogVisible"
|
||||
v-model:visible="exportColumnsDialogVisible"
|
||||
@ -381,6 +431,7 @@ import {
|
||||
deliveryB2bAvailableFields,
|
||||
deliveryColumns,
|
||||
buildDeliveryB2bColumns,
|
||||
buildB2bRowActions,
|
||||
buildB2bToolbarButtons,
|
||||
deliveryOrderToolbarButtons,
|
||||
type ToolbarButtonConfig,
|
||||
@ -402,6 +453,10 @@ const log = defineAsyncComponent(() => import('./component/log.vue'))
|
||||
const OrderExportProgressDialog = defineAsyncComponent(() => import('@/views/order/shared/component/OrderExportProgressDialog.vue'))
|
||||
const OrderExportColumnsDialog = defineAsyncComponent(() => import('./component/OrderExportColumnsDialog.vue'))
|
||||
const WavePlatformPrintPreviewDialog = defineAsyncComponent(() => import('@/views/order/waveOrder/component/WavePlatformPrintPreviewDialog.vue'))
|
||||
const B2bPrepFinishForm = defineAsyncComponent(() => import('./form/B2bPrepFinishForm.vue'))
|
||||
const B2bPickupPlateForm = defineAsyncComponent(() => import('./form/B2bPickupPlateForm.vue'))
|
||||
const B2bPickupForm = defineAsyncComponent(() => import('./form/B2bPickupForm.vue'))
|
||||
const B2bPrepForm = defineAsyncComponent(() => import('./form/B2bPrepForm.vue'))
|
||||
import { createOrderPageExport } from './utils/order-page-export'
|
||||
import { buildOrderWhereConditions, parseOrderListResponse, resolveOrderRecheckStatus } from '@/views/order/shared/orderListExport'
|
||||
import { useOrderListPageCleanup } from './utils/use-order-list-page-cleanup'
|
||||
@ -852,16 +907,33 @@ function removeTransferByOrderRow(value: string | number) {
|
||||
|
||||
toolbarActionMap.openTransferByOrdersDialog = openTransferByOrdersDialog
|
||||
|
||||
// B2B 作业(备货开始 / 备货完成 / 取消备货 / 提货 / 加急设置):仅「配送B2B订单」页签可用
|
||||
// B2B 作业(备货窗口 / 备货完成 / 取消备货 / 提货 / 分箱 / 加急设置):仅「配送B2B订单」页签可用
|
||||
const {
|
||||
b2bActionLoading,
|
||||
prepDialogVisible,
|
||||
prepRow,
|
||||
prepStarting,
|
||||
prepInfo,
|
||||
prepSnapshot,
|
||||
prepSnapshotLoading,
|
||||
openPrepDialog,
|
||||
closePrepDialog,
|
||||
savePrepPacking,
|
||||
savePrepPackingQuiet,
|
||||
submitPrepFinish,
|
||||
finishPrepDialogVisible,
|
||||
finishPrepRow,
|
||||
submitFinishPrep,
|
||||
handleStartPrep: handleB2bStartPrep,
|
||||
handleCancelPrep: handleB2bCancelPrep,
|
||||
openFinishPrepDialog: openB2bFinishPrepDialog,
|
||||
handlePickup: handleB2bPickup,
|
||||
openPickupDialog: openB2bPickupDialog,
|
||||
submitPickup,
|
||||
pickupDialogVisible,
|
||||
pickupRow,
|
||||
pickupPlateDialogVisible,
|
||||
pickupPlateRow,
|
||||
openPickupPlateDialog,
|
||||
submitPickupPlate,
|
||||
handleSetUrgent: handleB2bSetUrgent,
|
||||
handleCancelUrgent: handleB2bCancelUrgent
|
||||
} = useB2bActions({
|
||||
@ -869,10 +941,29 @@ const {
|
||||
onSuccess: () => loadData()
|
||||
})
|
||||
|
||||
toolbarActionMap.handleB2bStartPrep = handleB2bStartPrep
|
||||
/** 行内「操作」列(仅 B2B 页签):备货 / 确认提货 / 设置车牌(分箱在备货窗口内完成) */
|
||||
function handleB2bRowAction(command: string, row: any) {
|
||||
if (command === 'prep') {
|
||||
void openPrepDialog(row)
|
||||
return
|
||||
}
|
||||
if (command === 'pickup') {
|
||||
openB2bPickupDialog(row)
|
||||
return
|
||||
}
|
||||
if (command === 'plate') {
|
||||
openPickupPlateDialog(row)
|
||||
}
|
||||
}
|
||||
|
||||
/** 关闭备货窗口:询问是否取消备货(换人) */
|
||||
function handlePrepDialogVisibleChange(value: boolean) {
|
||||
if (!value) void closePrepDialog()
|
||||
}
|
||||
|
||||
toolbarActionMap.openB2bFinishPrepDialog = openB2bFinishPrepDialog
|
||||
toolbarActionMap.handleB2bCancelPrep = handleB2bCancelPrep
|
||||
toolbarActionMap.handleB2bPickup = handleB2bPickup
|
||||
toolbarActionMap.handleB2bPickup = openB2bPickupDialog
|
||||
toolbarActionMap.handleB2bSetUrgent = handleB2bSetUrgent
|
||||
toolbarActionMap.handleB2bCancelUrgent = handleB2bCancelUrgent
|
||||
|
||||
@ -1081,6 +1172,21 @@ function handleToolbarButtonClick(action: ToolbarButtonConfig['action']) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* B2B 行内「操作」列:三个链接按钮平铺、不换行 */
|
||||
.b2b-row-actions {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
gap: 8px;
|
||||
white-space: nowrap;
|
||||
|
||||
:deep(.el-button) {
|
||||
margin-left: 0;
|
||||
margin-right: 0;
|
||||
padding: 0;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
|
||||
<style lang="scss">
|
||||
|
||||
524
src/views/order/orderManagement/form/B2bPickupForm.vue
Normal file
524
src/views/order/orderManagement/form/B2bPickupForm.vue
Normal file
@ -0,0 +1,524 @@
|
||||
<template>
|
||||
<el-dialog
|
||||
:model-value="visible"
|
||||
class="b2b-pickup-dialog"
|
||||
width="min(680px, 96vw)"
|
||||
align-center
|
||||
append-to-body
|
||||
:show-close="false"
|
||||
:close-on-click-modal="false"
|
||||
:close-on-press-escape="!submitting"
|
||||
@update:model-value="handleVisibleChange"
|
||||
@closed="resetState"
|
||||
>
|
||||
<div class="task-panel">
|
||||
<header class="task-panel__head">
|
||||
<div class="task-panel__titles">
|
||||
<h2>确认提货</h2>
|
||||
<p>提货时间记为提交时刻并标记出库完成;可同时录入提货车牌与提货留证照片</p>
|
||||
</div>
|
||||
<button
|
||||
class="task-panel__close"
|
||||
type="button"
|
||||
aria-label="关闭"
|
||||
:disabled="submitting"
|
||||
@click="handleVisibleChange(false)"
|
||||
>
|
||||
<svg viewBox="0 0 12 12" fill="none">
|
||||
<path d="M1 1L11 11M11 1L1 11" stroke="currentColor" stroke-width="1.4" stroke-linecap="round" />
|
||||
</svg>
|
||||
</button>
|
||||
</header>
|
||||
|
||||
<div class="task-panel__body">
|
||||
<div class="task-panel__form">
|
||||
<div class="task-panel__field">
|
||||
<span class="task-panel__field-label">订单</span>
|
||||
<strong class="task-panel__field-value">
|
||||
{{ orderCode || '-' }}
|
||||
<span class="b2b-pickup__id">#{{ orderId ?? '-' }}</span>
|
||||
</strong>
|
||||
</div>
|
||||
|
||||
<div class="task-panel__field">
|
||||
<span class="task-panel__field-label">备货状态</span>
|
||||
<strong class="task-panel__field-value">{{ prepStatusText }}</strong>
|
||||
</div>
|
||||
|
||||
<div v-if="pickedUp" class="task-panel__field">
|
||||
<span class="task-panel__field-label">是否已提货</span>
|
||||
<strong class="task-panel__field-value">已提货(车牌锁定,仅可追加提货照片)</strong>
|
||||
</div>
|
||||
|
||||
<div class="task-panel__field task-panel__field--column">
|
||||
<span class="task-panel__field-label">提货车牌</span>
|
||||
<el-input
|
||||
v-model="plate"
|
||||
maxlength="20"
|
||||
clearable
|
||||
show-word-limit
|
||||
placeholder="可选,留空则不写入车牌"
|
||||
:disabled="submitting || pickedUp"
|
||||
/>
|
||||
</div>
|
||||
|
||||
<div class="task-panel__field task-panel__field--column">
|
||||
<span class="task-panel__field-label">
|
||||
提货照片
|
||||
<em class="b2b-pickup__count">{{ photoList.length }} / 20</em>
|
||||
</span>
|
||||
<el-upload
|
||||
v-model:file-list="photoList"
|
||||
action="#"
|
||||
list-type="picture-card"
|
||||
:auto-upload="false"
|
||||
:multiple="true"
|
||||
:limit="20"
|
||||
accept="image/*"
|
||||
:disabled="submitting"
|
||||
:on-change="handlePhotoChange"
|
||||
:on-preview="handlePhotoPreview"
|
||||
:on-exceed="handlePhotoExceed"
|
||||
class="b2b-pickup__upload"
|
||||
>
|
||||
<div class="b2b-pickup__upload-trigger">
|
||||
<el-icon><Plus /></el-icon>
|
||||
<span>上传照片</span>
|
||||
</div>
|
||||
</el-upload>
|
||||
<span class="b2b-pickup__upload-tip">
|
||||
支持 JPG / PNG·单张不超过 10MB,最多 20 张;提交后追加到订单提货照片,不覆盖已有照片
|
||||
</span>
|
||||
</div>
|
||||
|
||||
<p class="task-panel__form-tip task-panel__form-tip--warning">
|
||||
提交即完成提货并标记出库完成(订单随后迁移到「配送B2B订单」),要求备货已完成;车牌与照片随提货一并落库,提货后车牌锁定。
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<footer class="task-panel__foot">
|
||||
<span class="task-panel__hint">
|
||||
{{ uploadingCount > 0 ? `图片上传中(${uploadingCount})` : '车牌与照片均可留空' }}
|
||||
</span>
|
||||
<div class="task-panel__actions">
|
||||
<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>
|
||||
</div>
|
||||
</footer>
|
||||
</div>
|
||||
</el-dialog>
|
||||
|
||||
<el-image
|
||||
ref="previewImageRef"
|
||||
:src="previewUrl"
|
||||
:preview-src-list="previewSrcList"
|
||||
:initial-index="previewIndex"
|
||||
preview-teleported
|
||||
fit="contain"
|
||||
class="b2b-pickup__preview-trigger"
|
||||
/>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { computed, nextTick, ref, watch } from 'vue'
|
||||
import { ElMessage } from 'element-plus'
|
||||
import { Plus } from '@element-plus/icons-vue'
|
||||
import { uploadImageToCos } from '@/utils/cosImageUpload'
|
||||
import { translateB2bPrepStatus } from '../config/order-common-config'
|
||||
import type { B2bPickupPayload } from '../utils/use-b2b-actions'
|
||||
|
||||
/**
|
||||
* B2B 确认提货(order.pickupB2b)
|
||||
* 车牌与提货照片随提货一次提交:
|
||||
* - pickup_plate_number:车牌(归一化后落库)
|
||||
* - pickup_file_ids:提货照片(追加语义,business_type=b2b_pickup)
|
||||
*/
|
||||
const props = withDefaults(
|
||||
defineProps<{
|
||||
visible: boolean
|
||||
loading?: boolean
|
||||
/** 待提货订单行(id / delivery_order_code / prep_status / pickup_plate_number) */
|
||||
row?: any
|
||||
}>(),
|
||||
{ loading: false, row: null }
|
||||
)
|
||||
|
||||
const emit = defineEmits<{
|
||||
(e: 'update:visible', value: boolean): void
|
||||
(e: 'submit', payload: B2bPickupPayload): void
|
||||
}>()
|
||||
|
||||
type PhotoItem = {
|
||||
uid: number | string
|
||||
name: string
|
||||
url: string
|
||||
status: 'ready' | 'uploading' | 'success' | 'fail'
|
||||
fileId?: number
|
||||
raw?: File
|
||||
}
|
||||
|
||||
const MAX_PHOTO_COUNT = 20
|
||||
const MAX_PHOTO_SIZE = 10 * 1024 * 1024
|
||||
|
||||
const plate = ref('')
|
||||
const photoList = ref<PhotoItem[]>([])
|
||||
const uploadingCount = ref(0)
|
||||
|
||||
const previewImageRef = ref<any>()
|
||||
const previewUrl = ref('')
|
||||
const previewSrcList = ref<string[]>([])
|
||||
const previewIndex = ref(0)
|
||||
|
||||
const submitting = computed(() => !!props.loading)
|
||||
const orderId = computed(() => {
|
||||
const id = Number(props.row?.id ?? props.row?.order_id)
|
||||
return Number.isInteger(id) && id > 0 ? id : null
|
||||
})
|
||||
const orderCode = computed(() =>
|
||||
String(props.row?.delivery_order_code ?? props.row?.order_code ?? '')
|
||||
)
|
||||
const prepStatusText = computed(() => translateB2bPrepStatus(props.row?.prep_status))
|
||||
/** 已提货:车牌随提货锁定(仅允许追加提货照片) */
|
||||
const pickedUp = computed(() => String(props.row?.is_picked_up ?? '').trim().toUpperCase() === 'Y')
|
||||
const canSubmit = computed(() => !submitting.value && uploadingCount.value === 0 && orderId.value !== null)
|
||||
|
||||
/** 与后端一致:去掉空格与 ·/•/-/-/_ 分隔符后转大写 */
|
||||
function normalizePlate(value: string) {
|
||||
return value.replace(/[\s·•\--_]/g, '').toUpperCase()
|
||||
}
|
||||
|
||||
watch(
|
||||
() => props.visible,
|
||||
(visible) => {
|
||||
if (visible) {
|
||||
plate.value = String(props.row?.pickup_plate_number ?? '').trim()
|
||||
photoList.value = []
|
||||
}
|
||||
}
|
||||
)
|
||||
|
||||
function handleVisibleChange(next: boolean) {
|
||||
if (submitting.value) return
|
||||
emit('update:visible', next)
|
||||
}
|
||||
|
||||
function resetState() {
|
||||
plate.value = ''
|
||||
photoList.value = []
|
||||
uploadingCount.value = 0
|
||||
previewUrl.value = ''
|
||||
previewSrcList.value = []
|
||||
previewIndex.value = 0
|
||||
}
|
||||
|
||||
function handlePhotoExceed() {
|
||||
ElMessage.warning(`提货照片最多 ${MAX_PHOTO_COUNT} 张`)
|
||||
}
|
||||
|
||||
async function handlePhotoChange(uploadFile: any) {
|
||||
if (uploadFile.status !== 'ready' || !uploadFile.raw) return
|
||||
const raw = uploadFile.raw as File
|
||||
if (raw.size > MAX_PHOTO_SIZE) {
|
||||
ElMessage.warning('单张图片不能超过 10MB')
|
||||
photoList.value = photoList.value.filter((item) => item.uid !== uploadFile.uid)
|
||||
return
|
||||
}
|
||||
|
||||
const target = photoList.value.find((item) => item.uid === uploadFile.uid) as PhotoItem | undefined
|
||||
if (!target) return
|
||||
target.status = 'uploading'
|
||||
uploadingCount.value += 1
|
||||
if (!target.url) target.url = URL.createObjectURL(raw)
|
||||
|
||||
try {
|
||||
const res = await uploadImageToCos(raw, {
|
||||
type: 'b2b_pickup',
|
||||
...(orderId.value === null ? {} : { id: orderId.value })
|
||||
})
|
||||
const fileId = Number(res.fileId)
|
||||
if (!Number.isInteger(fileId) || fileId <= 0) {
|
||||
throw new Error('上传成功但未返回文件ID')
|
||||
}
|
||||
target.fileId = fileId
|
||||
target.uid = fileId
|
||||
target.name = raw.name
|
||||
if (res.fileUrl) target.url = res.fileUrl
|
||||
target.status = 'success'
|
||||
} catch (error: any) {
|
||||
target.status = 'fail'
|
||||
ElMessage.error(error?.message || '图片上传失败')
|
||||
} finally {
|
||||
uploadingCount.value = Math.max(0, uploadingCount.value - 1)
|
||||
}
|
||||
}
|
||||
|
||||
function handlePhotoPreview(uploadFile: any) {
|
||||
const urls = photoList.value.map((item) => item.url).filter(Boolean)
|
||||
const currentUrl = String(uploadFile?.url ?? '')
|
||||
const index = Math.max(0, urls.findIndex((url) => url === currentUrl))
|
||||
previewUrl.value = currentUrl || urls[index] || ''
|
||||
previewSrcList.value = urls.length ? urls : previewUrl.value ? [previewUrl.value] : []
|
||||
previewIndex.value = index
|
||||
|
||||
nextTick(() => {
|
||||
const imageEl = previewImageRef.value?.$el?.querySelector?.('img')
|
||||
imageEl?.click?.()
|
||||
})
|
||||
}
|
||||
|
||||
function submit() {
|
||||
if (submitting.value) return
|
||||
if (uploadingCount.value > 0) {
|
||||
ElMessage.warning('图片上传中,请稍候再提交')
|
||||
return
|
||||
}
|
||||
if (orderId.value === null) {
|
||||
ElMessage.error('所选订单缺少有效订单 ID,请刷新后重试')
|
||||
return
|
||||
}
|
||||
|
||||
const rawPlate = plate.value.trim()
|
||||
if (rawPlate.length > 20) {
|
||||
ElMessage.warning('车牌不能超过 20 个字符')
|
||||
return
|
||||
}
|
||||
const nextPlate = normalizePlate(rawPlate)
|
||||
if (nextPlate && !/^[\u4e00-\u9fa5A-Z][\u4e00-\u9fa5A-Z0-9]{4,9}$/.test(nextPlate)) {
|
||||
ElMessage.warning('车牌格式不正确:首字符为汉字或字母,整体 5~10 位汉字/字母/数字')
|
||||
return
|
||||
}
|
||||
|
||||
const failedPhoto = photoList.value.find((item) => item.status === 'fail')
|
||||
if (failedPhoto) {
|
||||
ElMessage.warning('存在上传失败的照片,请移除后重试')
|
||||
return
|
||||
}
|
||||
const fileIds = photoList.value
|
||||
.map((item) => item.fileId)
|
||||
.filter((fileId): fileId is number => Number.isInteger(fileId) && (fileId as number) > 0)
|
||||
|
||||
emit('submit', {
|
||||
pickup_plate_number: nextPlate || null,
|
||||
file_ids: fileIds
|
||||
})
|
||||
}
|
||||
</script>
|
||||
|
||||
<style scoped lang="scss">
|
||||
.b2b-pickup__id {
|
||||
margin-left: 6px;
|
||||
font-weight: 400;
|
||||
color: #909399;
|
||||
}
|
||||
|
||||
.b2b-pickup__count {
|
||||
margin-left: 6px;
|
||||
font-style: normal;
|
||||
color: #909399;
|
||||
}
|
||||
|
||||
.b2b-pickup__upload-tip {
|
||||
font-size: 12px;
|
||||
line-height: 18px;
|
||||
color: #909399;
|
||||
}
|
||||
|
||||
.b2b-pickup__upload {
|
||||
:deep(.el-upload--picture-card),
|
||||
:deep(.el-upload-list__item) {
|
||||
width: 76px;
|
||||
height: 76px;
|
||||
}
|
||||
|
||||
&-trigger {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
gap: 2px;
|
||||
font-size: 12px;
|
||||
color: #909399;
|
||||
}
|
||||
}
|
||||
|
||||
.b2b-pickup__preview-trigger {
|
||||
display: none;
|
||||
}
|
||||
|
||||
/* 面板结构 / 尺寸对齐其它 B2B 作业弹窗 */
|
||||
.task-panel {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
max-height: calc(100vh - 96px);
|
||||
background: #fff;
|
||||
color: #303133;
|
||||
|
||||
&__head {
|
||||
display: flex;
|
||||
align-items: flex-start;
|
||||
gap: 12px;
|
||||
padding: 16px;
|
||||
flex-shrink: 0;
|
||||
}
|
||||
|
||||
&__titles {
|
||||
flex: 1;
|
||||
min-width: 0;
|
||||
|
||||
h2 {
|
||||
margin: 0;
|
||||
font-size: 18px;
|
||||
line-height: 24px;
|
||||
font-weight: 400;
|
||||
color: #303133;
|
||||
}
|
||||
|
||||
p {
|
||||
margin: 4px 0 0;
|
||||
font-size: 12px;
|
||||
line-height: 18px;
|
||||
color: #909399;
|
||||
}
|
||||
}
|
||||
|
||||
&__close {
|
||||
width: 24px;
|
||||
height: 24px;
|
||||
flex: none;
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
border: none;
|
||||
border-radius: 4px;
|
||||
background: transparent;
|
||||
color: #909399;
|
||||
cursor: pointer;
|
||||
transition: color 0.2s;
|
||||
|
||||
svg {
|
||||
width: 12px;
|
||||
height: 12px;
|
||||
}
|
||||
|
||||
&:not(:disabled):hover {
|
||||
color: #409eff;
|
||||
}
|
||||
|
||||
&:disabled {
|
||||
cursor: not-allowed;
|
||||
opacity: 0.5;
|
||||
}
|
||||
}
|
||||
|
||||
&__body {
|
||||
padding: 12px 16px 0;
|
||||
min-height: 0;
|
||||
overflow-y: auto;
|
||||
}
|
||||
|
||||
&__form {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 8px;
|
||||
}
|
||||
|
||||
&__field {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
gap: 16px;
|
||||
min-height: 40px;
|
||||
padding: 8px 12px;
|
||||
border: 1px solid #ebeef5;
|
||||
border-radius: 4px;
|
||||
background: #fafafa;
|
||||
|
||||
&--column {
|
||||
flex-direction: column;
|
||||
align-items: stretch;
|
||||
gap: 6px;
|
||||
}
|
||||
}
|
||||
|
||||
&__field-label {
|
||||
font-size: 12px;
|
||||
line-height: 20px;
|
||||
color: #606266;
|
||||
flex-shrink: 0;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
&__field-value {
|
||||
font-size: 13px;
|
||||
font-weight: 500;
|
||||
color: #303133;
|
||||
text-align: right;
|
||||
word-break: break-all;
|
||||
}
|
||||
|
||||
&__form-tip {
|
||||
margin: 8px 0 0;
|
||||
padding: 8px 12px;
|
||||
border-radius: 4px;
|
||||
background: #f4f4f5;
|
||||
font-size: 12px;
|
||||
line-height: 18px;
|
||||
color: #909399;
|
||||
|
||||
&--warning {
|
||||
background: #fdf6ec;
|
||||
color: #e6a23c;
|
||||
}
|
||||
}
|
||||
|
||||
&__foot {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
gap: 12px;
|
||||
padding: 12px 16px 16px;
|
||||
flex-shrink: 0;
|
||||
}
|
||||
|
||||
&__hint {
|
||||
font-size: 12px;
|
||||
color: #909399;
|
||||
}
|
||||
|
||||
&__actions {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 6px;
|
||||
|
||||
:deep(.el-button) {
|
||||
margin-left: 0;
|
||||
margin-right: 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
</style>
|
||||
|
||||
<style lang="scss">
|
||||
/* el-dialog 会被 append 到 body:去掉默认头/内边距,统一交给面板 */
|
||||
.el-dialog.b2b-pickup-dialog {
|
||||
padding: 0;
|
||||
overflow: hidden;
|
||||
|
||||
.el-dialog__header {
|
||||
display: none;
|
||||
}
|
||||
|
||||
.el-dialog__body {
|
||||
padding: 0;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
330
src/views/order/orderManagement/form/B2bPickupPlateForm.vue
Normal file
330
src/views/order/orderManagement/form/B2bPickupPlateForm.vue
Normal file
@ -0,0 +1,330 @@
|
||||
<template>
|
||||
<el-dialog
|
||||
:model-value="visible"
|
||||
class="b2b-pickup-plate-dialog"
|
||||
width="min(560px, 94vw)"
|
||||
align-center
|
||||
append-to-body
|
||||
:show-close="false"
|
||||
:close-on-click-modal="false"
|
||||
:close-on-press-escape="!loading"
|
||||
@update:model-value="handleVisibleChange"
|
||||
@closed="resetState"
|
||||
>
|
||||
<div class="task-panel">
|
||||
<header class="task-panel__head">
|
||||
<div class="task-panel__titles">
|
||||
<h2>设置提货车牌</h2>
|
||||
<p>录入或修改 B2B 订单提货车牌,提货后车牌锁定不可修改</p>
|
||||
</div>
|
||||
<button
|
||||
class="task-panel__close"
|
||||
type="button"
|
||||
aria-label="关闭"
|
||||
:disabled="loading"
|
||||
@click="handleVisibleChange(false)"
|
||||
>
|
||||
<svg viewBox="0 0 12 12" fill="none">
|
||||
<path d="M1 1L11 11M11 1L1 11" stroke="currentColor" stroke-width="1.4" stroke-linecap="round" />
|
||||
</svg>
|
||||
</button>
|
||||
</header>
|
||||
|
||||
<div class="task-panel__body">
|
||||
<div class="task-panel__form">
|
||||
<div class="task-panel__field">
|
||||
<span class="task-panel__field-label">订单</span>
|
||||
<strong class="task-panel__field-value">
|
||||
{{ orderCode || '-' }}
|
||||
<span class="b2b-pickup-plate__id">#{{ orderId ?? '-' }}</span>
|
||||
</strong>
|
||||
</div>
|
||||
|
||||
<div class="task-panel__field">
|
||||
<span class="task-panel__field-label">当前车牌</span>
|
||||
<strong class="task-panel__field-value">{{ currentPlate || '未设置' }}</strong>
|
||||
</div>
|
||||
|
||||
<div class="task-panel__field task-panel__field--column">
|
||||
<span class="task-panel__field-label">提货车牌</span>
|
||||
<el-input
|
||||
v-model="form.pickup_plate_number"
|
||||
maxlength="20"
|
||||
clearable
|
||||
show-word-limit
|
||||
placeholder="留空保存表示清空车牌"
|
||||
:disabled="loading"
|
||||
/>
|
||||
</div>
|
||||
|
||||
<p class="task-panel__form-tip">
|
||||
车牌保存时会去掉空格与「·/•/-/-/_」分隔符并转大写;有效车牌为 5~10 位汉字/字母/数字组合,首字符需为汉字或字母。
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<footer class="task-panel__foot">
|
||||
<span class="task-panel__hint">提货照片在「确认提货」弹窗中随提货一并提交</span>
|
||||
<div class="task-panel__actions">
|
||||
<el-button size="small" :disabled="loading" @click="handleVisibleChange(false)">取消</el-button>
|
||||
<el-button size="small" type="primary" :loading="loading" :disabled="!canSubmit" @click="submit">
|
||||
保存
|
||||
</el-button>
|
||||
</div>
|
||||
</footer>
|
||||
</div>
|
||||
</el-dialog>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { computed, reactive, watch } from 'vue'
|
||||
import { ElMessage } from 'element-plus'
|
||||
import type { B2bPickupPlatePayload } from '../utils/use-b2b-actions'
|
||||
|
||||
/**
|
||||
* B2B 提货车牌(order.setB2bPickupPlate)
|
||||
* 单订单作业:pickup_plate_number 键必传,空字符串表示清空车牌。
|
||||
*/
|
||||
const props = withDefaults(
|
||||
defineProps<{
|
||||
visible: boolean
|
||||
loading?: boolean
|
||||
/** 行内操作的订单行(取 id 作为订单 ID、pickup_plate_number 作为当前车牌) */
|
||||
row?: any
|
||||
}>(),
|
||||
{ loading: false, row: null }
|
||||
)
|
||||
|
||||
const emit = defineEmits<{
|
||||
(e: 'update:visible', value: boolean): void
|
||||
(e: 'submit', payload: B2bPickupPlatePayload): void
|
||||
}>()
|
||||
|
||||
const form = reactive<{ pickup_plate_number: string }>({
|
||||
pickup_plate_number: ''
|
||||
})
|
||||
|
||||
const orderId = computed(() => {
|
||||
const id = Number(props.row?.id ?? props.row?.order_id)
|
||||
return Number.isInteger(id) && id > 0 ? id : null
|
||||
})
|
||||
const orderCode = computed(() =>
|
||||
String(props.row?.delivery_order_code ?? props.row?.order_code ?? '')
|
||||
)
|
||||
const currentPlate = computed(() => String(props.row?.pickup_plate_number ?? '').trim())
|
||||
const canSubmit = computed(() => !props.loading && orderId.value !== null)
|
||||
|
||||
/** 与后端一致:去掉空格与 ·/•/-/-/_ 分隔符后转大写 */
|
||||
function normalizePlate(value: string) {
|
||||
return value.replace(/[\s·•\--_]/g, '').toUpperCase()
|
||||
}
|
||||
|
||||
// 每次打开时以当前车牌回填,便于在原值上修改
|
||||
watch(
|
||||
() => props.visible,
|
||||
(visible) => {
|
||||
if (visible) {
|
||||
form.pickup_plate_number = currentPlate.value
|
||||
}
|
||||
}
|
||||
)
|
||||
|
||||
function handleVisibleChange(next: boolean) {
|
||||
if (props.loading) return
|
||||
emit('update:visible', next)
|
||||
}
|
||||
|
||||
function resetState() {
|
||||
form.pickup_plate_number = ''
|
||||
}
|
||||
|
||||
function submit() {
|
||||
if (props.loading) return
|
||||
if (orderId.value === null) {
|
||||
ElMessage.error('所选订单缺少有效订单 ID,请刷新后重试')
|
||||
return
|
||||
}
|
||||
const raw = form.pickup_plate_number.trim()
|
||||
if (raw.length > 20) {
|
||||
ElMessage.warning('车牌不能超过 20 个字符')
|
||||
return
|
||||
}
|
||||
const plate = normalizePlate(raw)
|
||||
if (plate && !/^[\u4e00-\u9fa5A-Z][\u4e00-\u9fa5A-Z0-9]{4,9}$/.test(plate)) {
|
||||
ElMessage.warning('车牌格式不正确:首字符为汉字或字母,整体 5~10 位汉字/字母/数字')
|
||||
return
|
||||
}
|
||||
emit('submit', { pickup_plate_number: plate || null })
|
||||
}
|
||||
</script>
|
||||
|
||||
<style scoped lang="scss">
|
||||
.b2b-pickup-plate__id {
|
||||
margin-left: 6px;
|
||||
font-weight: 400;
|
||||
color: #909399;
|
||||
}
|
||||
|
||||
/* 面板结构 / 尺寸对齐其它 B2B 作业弹窗 */
|
||||
.task-panel {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
max-height: calc(100vh - 96px);
|
||||
background: #fff;
|
||||
color: #303133;
|
||||
|
||||
&__head {
|
||||
display: flex;
|
||||
align-items: flex-start;
|
||||
gap: 12px;
|
||||
padding: 16px;
|
||||
flex-shrink: 0;
|
||||
}
|
||||
|
||||
&__titles {
|
||||
flex: 1;
|
||||
min-width: 0;
|
||||
|
||||
h2 {
|
||||
margin: 0;
|
||||
font-size: 18px;
|
||||
line-height: 24px;
|
||||
font-weight: 400;
|
||||
color: #303133;
|
||||
}
|
||||
|
||||
p {
|
||||
margin: 4px 0 0;
|
||||
font-size: 12px;
|
||||
line-height: 18px;
|
||||
color: #909399;
|
||||
}
|
||||
}
|
||||
|
||||
&__close {
|
||||
width: 24px;
|
||||
height: 24px;
|
||||
flex: none;
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
border: none;
|
||||
border-radius: 4px;
|
||||
background: transparent;
|
||||
color: #909399;
|
||||
cursor: pointer;
|
||||
transition: color 0.2s;
|
||||
|
||||
svg {
|
||||
width: 12px;
|
||||
height: 12px;
|
||||
}
|
||||
|
||||
&:not(:disabled):hover {
|
||||
color: #409eff;
|
||||
}
|
||||
|
||||
&:disabled {
|
||||
cursor: not-allowed;
|
||||
opacity: 0.5;
|
||||
}
|
||||
}
|
||||
|
||||
&__body {
|
||||
padding: 12px 16px 0;
|
||||
min-height: 0;
|
||||
overflow-y: auto;
|
||||
}
|
||||
|
||||
&__form {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 8px;
|
||||
}
|
||||
|
||||
&__field {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
gap: 16px;
|
||||
min-height: 40px;
|
||||
padding: 8px 12px;
|
||||
border: 1px solid #ebeef5;
|
||||
border-radius: 4px;
|
||||
background: #fafafa;
|
||||
|
||||
&--column {
|
||||
flex-direction: column;
|
||||
align-items: stretch;
|
||||
gap: 6px;
|
||||
}
|
||||
}
|
||||
|
||||
&__field-label {
|
||||
font-size: 12px;
|
||||
line-height: 20px;
|
||||
color: #606266;
|
||||
flex-shrink: 0;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
&__field-value {
|
||||
font-size: 13px;
|
||||
font-weight: 500;
|
||||
color: #303133;
|
||||
text-align: right;
|
||||
word-break: break-all;
|
||||
}
|
||||
|
||||
&__form-tip {
|
||||
margin: 8px 0 0;
|
||||
padding: 8px 12px;
|
||||
border-radius: 4px;
|
||||
background: #f4f4f5;
|
||||
font-size: 12px;
|
||||
line-height: 18px;
|
||||
color: #909399;
|
||||
}
|
||||
|
||||
&__foot {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
gap: 12px;
|
||||
padding: 12px 16px 16px;
|
||||
flex-shrink: 0;
|
||||
}
|
||||
|
||||
&__hint {
|
||||
font-size: 12px;
|
||||
color: #909399;
|
||||
}
|
||||
|
||||
&__actions {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 6px;
|
||||
|
||||
:deep(.el-button) {
|
||||
margin-left: 0;
|
||||
margin-right: 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
</style>
|
||||
|
||||
<style lang="scss">
|
||||
/* el-dialog 会被 append 到 body:去掉默认头/内边距,统一交给面板 */
|
||||
.el-dialog.b2b-pickup-plate-dialog {
|
||||
padding: 0;
|
||||
overflow: hidden;
|
||||
|
||||
.el-dialog__header {
|
||||
display: none;
|
||||
}
|
||||
|
||||
.el-dialog__body {
|
||||
padding: 0;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
@ -131,13 +131,14 @@ const canSubmit = computed(
|
||||
form.total_box_count >= 0
|
||||
)
|
||||
|
||||
// 每次打开时重置表单(按订单维度重新填写)
|
||||
// 每次打开时重置表单(按订单维度重新填写);总箱数默认取订单当前箱号数(分箱保存时同步)
|
||||
watch(
|
||||
() => props.visible,
|
||||
(visible) => {
|
||||
if (visible) {
|
||||
form.prep_remark = ''
|
||||
form.total_box_count = 0
|
||||
const boxCount = Number(props.row?.total_box_count ?? 0)
|
||||
form.total_box_count = Number.isInteger(boxCount) && boxCount > 0 ? boxCount : 0
|
||||
}
|
||||
}
|
||||
)
|
||||
|
||||
1364
src/views/order/orderManagement/form/B2bPrepForm.vue
Normal file
1364
src/views/order/orderManagement/form/B2bPrepForm.vue
Normal file
File diff suppressed because it is too large
Load Diff
@ -1,4 +1,4 @@
|
||||
<template>
|
||||
<template>
|
||||
<div class="order-sub-container">
|
||||
<scan-box
|
||||
ref="scanBox"
|
||||
@ -130,6 +130,22 @@
|
||||
</span>
|
||||
</template>
|
||||
|
||||
<!-- B2B 行内操作(按状态动态):备货(窗口内完成分箱)/ 确认提货 / 设置车牌 -->
|
||||
<template #column-actions="{ row }">
|
||||
<div class="b2b-row-actions">
|
||||
<el-button
|
||||
v-for="action in buildB2bRowActions(row)"
|
||||
:key="action.key"
|
||||
link
|
||||
type="primary"
|
||||
size="small"
|
||||
@click.stop="handleB2bRowAction(action.key, row)"
|
||||
>
|
||||
{{ action.label }}
|
||||
</el-button>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<template #empty>
|
||||
<div class="empty-tip">{{ b2b ? '暂无待处理B2B订单' : '暂无待处理订单' }}</div>
|
||||
</template>
|
||||
@ -417,6 +433,22 @@
|
||||
@success="handleCancelB2bSuccess"
|
||||
/>
|
||||
|
||||
<!-- B2B 备货作业窗口(行内「开始备货」):打开即 startB2bPrep,内含分箱登记 + 备货完成 -->
|
||||
<b2b-prep-form
|
||||
v-if="b2b && prepDialogVisible"
|
||||
:visible="prepDialogVisible"
|
||||
:starting="prepStarting"
|
||||
:submitting="b2bActionLoading"
|
||||
:snapshot-loading="prepSnapshotLoading"
|
||||
:row="prepRow"
|
||||
:info="prepInfo"
|
||||
:snapshot="prepSnapshot"
|
||||
:save-request="savePrepPackingQuiet"
|
||||
@update:visible="handlePrepDialogVisibleChange"
|
||||
@save-packing="savePrepPacking"
|
||||
@submit-finish="submitPrepFinish"
|
||||
/>
|
||||
|
||||
<!-- B2B 备货完成(order.finishB2bPrep):必填备货备注 + 总箱数,完成时同步扣减库存 -->
|
||||
<b2b-prep-finish-form
|
||||
v-if="b2b && finishPrepDialogVisible"
|
||||
@ -426,6 +458,24 @@
|
||||
@submit="submitFinishPrep"
|
||||
/>
|
||||
|
||||
<!-- B2B 提货车牌(order.setB2bPickupPlate):行内「设置」打开,留空保存表示清空 -->
|
||||
<b2b-pickup-plate-form
|
||||
v-if="b2b && pickupPlateDialogVisible"
|
||||
v-model:visible="pickupPlateDialogVisible"
|
||||
:loading="b2bActionLoading"
|
||||
:row="pickupPlateRow"
|
||||
@submit="submitPickupPlate"
|
||||
/>
|
||||
|
||||
<!-- B2B 确认提货(order.pickupB2b):车牌 + 提货照片随提货一次提交 -->
|
||||
<b2b-pickup-form
|
||||
v-if="b2b && pickupDialogVisible"
|
||||
v-model:visible="pickupDialogVisible"
|
||||
:loading="b2bActionLoading"
|
||||
:row="pickupRow"
|
||||
@submit="submitPickup"
|
||||
/>
|
||||
|
||||
<wave-platform-print-preview-dialog
|
||||
v-if="batchPrintDialogVisible"
|
||||
v-model="batchPrintDialogVisible"
|
||||
@ -486,6 +536,7 @@ import { loadExpressListCached, loadPlatformListCached, loadStoresCached } from
|
||||
import {
|
||||
buildPendingStyleColumns,
|
||||
buildPendingB2bColumns,
|
||||
buildB2bRowActions,
|
||||
buildB2bToolbarButtons,
|
||||
pendingAvailableFields,
|
||||
pendingB2bAvailableFields,
|
||||
@ -537,6 +588,9 @@ const WavePlatformPrintPreviewDialog = defineAsyncComponent(() => import('@/view
|
||||
const ConvertToB2bForm = defineAsyncComponent(() => import('./form/ConvertToB2bForm.vue'))
|
||||
const CancelB2bForm = defineAsyncComponent(() => import('./form/CancelB2bForm.vue'))
|
||||
const B2bPrepFinishForm = defineAsyncComponent(() => import('./form/B2bPrepFinishForm.vue'))
|
||||
const B2bPickupPlateForm = defineAsyncComponent(() => import('./form/B2bPickupPlateForm.vue'))
|
||||
const B2bPickupForm = defineAsyncComponent(() => import('./form/B2bPickupForm.vue'))
|
||||
const B2bPrepForm = defineAsyncComponent(() => import('./form/B2bPrepForm.vue'))
|
||||
|
||||
const scanBox = ref<any>(null)
|
||||
const upperTable = ref<any>(null)
|
||||
@ -973,16 +1027,33 @@ function handleCancelB2bSuccess() {
|
||||
loadData()
|
||||
}
|
||||
|
||||
// B2B 作业(备货开始 / 备货完成 / 取消备货 / 提货 / 加急设置):仅 B2B 页签可用
|
||||
// B2B 作业(备货窗口 / 备货完成 / 取消备货 / 提货 / 分箱 / 加急设置):仅 B2B 页签可用
|
||||
const {
|
||||
b2bActionLoading,
|
||||
prepDialogVisible,
|
||||
prepRow,
|
||||
prepStarting,
|
||||
prepInfo,
|
||||
prepSnapshot,
|
||||
prepSnapshotLoading,
|
||||
openPrepDialog,
|
||||
closePrepDialog,
|
||||
savePrepPacking,
|
||||
savePrepPackingQuiet,
|
||||
submitPrepFinish,
|
||||
finishPrepDialogVisible,
|
||||
finishPrepRow,
|
||||
submitFinishPrep,
|
||||
handleStartPrep: handleB2bStartPrep,
|
||||
handleCancelPrep: handleB2bCancelPrep,
|
||||
openFinishPrepDialog: openB2bFinishPrepDialog,
|
||||
handlePickup: handleB2bPickup,
|
||||
openPickupDialog: openB2bPickupDialog,
|
||||
submitPickup,
|
||||
pickupDialogVisible,
|
||||
pickupRow,
|
||||
pickupPlateDialogVisible,
|
||||
pickupPlateRow,
|
||||
openPickupPlateDialog,
|
||||
submitPickupPlate,
|
||||
handleSetUrgent: handleB2bSetUrgent,
|
||||
handleCancelUrgent: handleB2bCancelUrgent
|
||||
} = useB2bActions({
|
||||
@ -990,6 +1061,26 @@ const {
|
||||
onSuccess: () => loadData()
|
||||
})
|
||||
|
||||
/** 行内「操作」列(仅 B2B 页签):备货 / 确认提货 / 设置车牌(分箱在备货窗口内完成) */
|
||||
function handleB2bRowAction(command: string, row: any) {
|
||||
if (command === 'prep') {
|
||||
void openPrepDialog(row)
|
||||
return
|
||||
}
|
||||
if (command === 'pickup') {
|
||||
openB2bPickupDialog(row)
|
||||
return
|
||||
}
|
||||
if (command === 'plate') {
|
||||
openPickupPlateDialog(row)
|
||||
}
|
||||
}
|
||||
|
||||
/** 关闭备货窗口:询问是否取消备货(换人) */
|
||||
function handlePrepDialogVisibleChange(value: boolean) {
|
||||
if (!value) void closePrepDialog()
|
||||
}
|
||||
|
||||
/** 取消 B2B 弹窗移除某个已选订单:同步快照行并取消列表勾选 */
|
||||
function removeCancelB2bRow(value: string | number) {
|
||||
const target = String(value)
|
||||
@ -1227,10 +1318,9 @@ function removeQuickRecheckOrder(value: string | number) {
|
||||
toolbarActionMap['openResolveExceptionDialog'] = openResolveExceptionDialog
|
||||
toolbarActionMap['openConvertToB2bDialog'] = openConvertToB2bDialog
|
||||
toolbarActionMap['openCancelB2bDialog'] = openCancelB2bDialog
|
||||
toolbarActionMap['handleB2bStartPrep'] = handleB2bStartPrep
|
||||
toolbarActionMap['openB2bFinishPrepDialog'] = openB2bFinishPrepDialog
|
||||
toolbarActionMap['handleB2bCancelPrep'] = handleB2bCancelPrep
|
||||
toolbarActionMap['handleB2bPickup'] = handleB2bPickup
|
||||
toolbarActionMap['openB2bFinishPrepDialog'] = openB2bFinishPrepDialog
|
||||
toolbarActionMap['handleB2bPickup'] = openB2bPickupDialog
|
||||
toolbarActionMap['handleB2bSetUrgent'] = handleB2bSetUrgent
|
||||
toolbarActionMap['handleB2bCancelUrgent'] = handleB2bCancelUrgent
|
||||
toolbarActionMap['handleBatchPrint'] = handleBatchPrint
|
||||
@ -1594,6 +1684,21 @@ async function handleConfirmInterceptBatch() {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* B2B 行内「操作」列:三个链接按钮平铺、不换行 */
|
||||
.b2b-row-actions {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
gap: 8px;
|
||||
white-space: nowrap;
|
||||
|
||||
:deep(.el-button) {
|
||||
margin-left: 0;
|
||||
margin-right: 0;
|
||||
padding: 0;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
|
||||
<style lang="scss">
|
||||
|
||||
@ -22,7 +22,9 @@ export async function exportUpperTableRows(options: ExportOptions) {
|
||||
// xlsx 体积较大(约 850KB),只在真正导出时加载,避免进入首屏依赖图
|
||||
const XLSX = await import('xlsx')
|
||||
const { rows, columns, fileName = `export-${Date.now()}.xlsx`, transformCell } = options
|
||||
const exportColumns = (columns || []).filter((column) => !!column.prop)
|
||||
const exportColumns = (columns || []).filter(
|
||||
(column) => !!column.prop && column.prop !== 'actions'
|
||||
)
|
||||
const exportData = (rows || []).map((row, index) => {
|
||||
const mapped: Record<string, any> = {}
|
||||
exportColumns.forEach((column) => {
|
||||
|
||||
@ -6,7 +6,15 @@ import {
|
||||
orderPendingOrderFinishB2bPrep,
|
||||
orderPendingOrderPickupB2b,
|
||||
orderPendingOrderSetB2bUrgent,
|
||||
orderPendingOrderCancelB2bUrgent
|
||||
orderPendingOrderCancelB2bUrgent,
|
||||
orderPendingOrderSetB2bPickupPlate,
|
||||
orderPendingOrderGetB2bPackingSnapshot,
|
||||
orderPendingOrderUpdateB2bPackingItems,
|
||||
orderPendingOrderUpdateB2bOrderImages
|
||||
} from '@/api/order.pendingorder/orderpendingOrder'
|
||||
import type {
|
||||
PendingOrderB2bPackingItem,
|
||||
PendingOrderB2bPackingSnapshot
|
||||
} from '@/api/order.pendingorder/orderpendingOrder'
|
||||
|
||||
/** 备货完成提交内容(order.finishB2bPrep 必填项) */
|
||||
@ -17,6 +25,35 @@ export type B2bPrepFinishPayload = {
|
||||
total_box_count: number
|
||||
}
|
||||
|
||||
/**
|
||||
* 提货设置提交内容(一次提交)
|
||||
* - pickup_plate_number:随 order.pickupB2b 一并写入提货车牌(null / 空串表示沿用原值)
|
||||
* - file_ids:order.pickupB2b 的 pickup_file_ids(追加语义)
|
||||
*/
|
||||
export type B2bPickupPayload = {
|
||||
pickup_plate_number: string | null
|
||||
file_ids: number[]
|
||||
}
|
||||
|
||||
/** 提货车牌提交内容(order.setB2bPickupPlate;null 表示清空) */
|
||||
export type B2bPickupPlatePayload = {
|
||||
pickup_plate_number: string | null
|
||||
}
|
||||
|
||||
/** 分箱明细提交内容(order.updateB2bPackingItems:整单全量替换) */
|
||||
export type B2bPackingPayload = {
|
||||
items: PendingOrderB2bPackingItem[]
|
||||
}
|
||||
|
||||
/** 备货窗口内的分箱快照(order.getB2bPackingSnapshot) */
|
||||
export type B2bPackingSnapshot = PendingOrderB2bPackingSnapshot
|
||||
|
||||
/** 备货窗口提交完成:备注 + 总箱数 + 备货照片 file_id */
|
||||
export type B2bPrepFinishSubmitPayload = B2bPrepFinishPayload & {
|
||||
/** 备货留证照片(order.updateB2bOrderImages),空数组表示不维护照片 */
|
||||
file_ids: number[]
|
||||
}
|
||||
|
||||
type UseB2bActionsOptions = {
|
||||
/** 当前页签勾选行 */
|
||||
getSelectionRows: () => any[]
|
||||
@ -77,13 +114,54 @@ function buildUrgentResultMessage(data: Record<string, any>, label: string) {
|
||||
}
|
||||
|
||||
/**
|
||||
* B2B 作业动作(备货开始 / 备货完成 / 取消备货 / 提货 / 设置加急 / 取消加急)。
|
||||
* order.finishB2bPrep 齐套校验失败文案(data.item_mismatches):
|
||||
* 「分箱数量与应拣不一致:SKU-A 应拣 5/已分箱 3、SKU-B 应拣 2/已分箱 0」
|
||||
*/
|
||||
function buildPrepMismatchText(res: any): string {
|
||||
const data = pickData(res)
|
||||
const list = Array.isArray(data.item_mismatches) ? data.item_mismatches : []
|
||||
if (!list.length) return ''
|
||||
const texts = list
|
||||
.slice(0, 5)
|
||||
.map((item: any) => {
|
||||
const name = String(item?.item_code ?? item?.item_name ?? item?.order_item_id ?? '').trim()
|
||||
const plan = Number(item?.plan_qty ?? 0)
|
||||
const packed = Number(item?.packed_quantity ?? 0)
|
||||
return `${name || '商品'} 应拣 ${plan}/已分箱 ${packed}`
|
||||
})
|
||||
.filter(Boolean)
|
||||
if (!texts.length) return ''
|
||||
const suffix = list.length > 5 ? ` 等 ${list.length} 行` : ''
|
||||
return `分箱数量与应拣不一致${suffix}:${texts.join('、')}`
|
||||
}
|
||||
|
||||
/**
|
||||
* B2B 作业动作(备货开始 / 备货完成 / 取消备货 / 提货(车牌 + 照片)/ 提货车牌 / 设置加急 / 取消加急)。
|
||||
* 两个 B2B 页签(待处理B2B、配送B2B)共用;普通订单页签不调用。
|
||||
*/
|
||||
export function useB2bActions(options: UseB2bActionsOptions) {
|
||||
const b2bActionLoading = ref(false)
|
||||
/** 备货窗口(行内「开始备货」打开,打开即调用 order.startB2bPrep 激活备货) */
|
||||
const prepDialogVisible = ref(false)
|
||||
const prepRow = ref<any>(null)
|
||||
const prepStarting = ref(false)
|
||||
const prepInfo = ref<Record<string, any> | null>(null)
|
||||
/** 本窗口内是否由当前工号激活了备货(关闭时用于询问是否取消备货换人) */
|
||||
const prepActivated = ref(false)
|
||||
/** 关闭备货窗口的确认流程进行中(防止遮罩/X/ESC 重复触发) */
|
||||
const prepClosing = ref(false)
|
||||
/** 备货窗口内的分箱快照与提交中状态 */
|
||||
const prepSnapshot = ref<B2bPackingSnapshot | null>(null)
|
||||
const prepSnapshotLoading = ref(false)
|
||||
const finishPrepDialogVisible = ref(false)
|
||||
const finishPrepRow = ref<any>(null)
|
||||
const pickupPlateDialogVisible = ref(false)
|
||||
const pickupPlateRow = ref<any>(null)
|
||||
/** 提货弹窗(车牌 + 照片一次性提交,order.pickupB2b) */
|
||||
const pickupDialogVisible = ref(false)
|
||||
const pickupRow = ref<any>(null)
|
||||
/** 分箱静默保存中(备货窗口自动保存用,独立于 b2bActionLoading,避免按钮/弹窗闪 loading) */
|
||||
const packingSaving = ref(false)
|
||||
|
||||
function requireSelection(emptyText = '请先勾选 B2B 订单') {
|
||||
const rows = options.getSelectionRows() || []
|
||||
@ -148,26 +226,264 @@ export function useB2bActions(options: UseB2bActionsOptions) {
|
||||
}
|
||||
}
|
||||
|
||||
/** order.startB2bPrep:备货开始(操作人取当前登录工号,同工号重复开始幂等) */
|
||||
async function handleStartPrep() {
|
||||
const target = requireSingleRow('开始备货')
|
||||
if (!target) return
|
||||
const ok = await confirm(
|
||||
`确定为订单 ${resolveRowLabel(target.row)} 开始备货吗?\n备货人取当前登录工号;重复开始会保留首次开始时间。`,
|
||||
'开始备货',
|
||||
'info'
|
||||
)
|
||||
if (!ok) return
|
||||
await run(
|
||||
() => orderPendingOrderStartB2bPrep({ ids: [target.id] }),
|
||||
/**
|
||||
* order.startB2bPrep:行内「开始备货」→ 打开备货窗口,打开即激活备货(当前登录工号)。
|
||||
* - 打开前校验:已取消 / 已备货完成 / 已被其他工号开始 均拦截
|
||||
* - 关闭窗口时询问是否取消备货(换人作业),确认后走 order.cancelB2bPrep
|
||||
*/
|
||||
async function openPrepDialog(row: any) {
|
||||
const id = toOrderId(row?.id ?? row?.order_id)
|
||||
if (id === null) {
|
||||
ElMessage.error('所选订单缺少有效订单 ID,请刷新后重试')
|
||||
return
|
||||
}
|
||||
if (String(row?.status ?? '').trim().toLowerCase() === 'cancel') {
|
||||
ElMessage.warning('该订单已取消,不允许备货')
|
||||
return
|
||||
}
|
||||
const prepStatus = String(row?.prep_status ?? '').trim().toLowerCase()
|
||||
if (prepStatus === 'fin') {
|
||||
ElMessage.warning('该订单备货已完成,无需再次开始备货')
|
||||
return
|
||||
}
|
||||
|
||||
prepRow.value = row
|
||||
prepInfo.value = null
|
||||
prepActivated.value = false
|
||||
prepDialogVisible.value = true
|
||||
prepStarting.value = true
|
||||
try {
|
||||
const res: any = await orderPendingOrderStartB2bPrep({ ids: [id] })
|
||||
if (!isOkCode(res)) {
|
||||
ElMessage.error(res?.message || '开始备货失败')
|
||||
prepDialogVisible.value = false
|
||||
prepRow.value = null
|
||||
return
|
||||
}
|
||||
const data = pickData(res)
|
||||
prepInfo.value = data
|
||||
prepActivated.value = true
|
||||
const operator = String(data.prep_operator_name ?? data.prep_operator_id ?? '').trim()
|
||||
const idempotent = Array.isArray(data.idempotent_order_ids) && data.idempotent_order_ids.length > 0
|
||||
ElMessage.success(
|
||||
idempotent
|
||||
? `备货已在进行中${operator ? `(备货人 ${operator})` : ''}`
|
||||
: `已开始备货${operator ? `(备货人 ${operator})` : ''}`
|
||||
)
|
||||
options.onSuccess?.()
|
||||
} catch {
|
||||
// 请求层已统一提示错误
|
||||
prepDialogVisible.value = false
|
||||
prepRow.value = null
|
||||
} finally {
|
||||
prepStarting.value = false
|
||||
}
|
||||
|
||||
// 备货窗口主体是分箱作业:激活成功后加载分箱快照
|
||||
if (prepDialogVisible.value) await loadPrepSnapshot(id)
|
||||
}
|
||||
|
||||
/** 加载(刷新)备货窗口内的分箱快照 */
|
||||
async function loadPrepSnapshot(id: number) {
|
||||
prepSnapshotLoading.value = true
|
||||
try {
|
||||
const res: any = await orderPendingOrderGetB2bPackingSnapshot({ ids: [id] })
|
||||
if (!isOkCode(res)) {
|
||||
ElMessage.error(res?.message || '获取分箱明细失败')
|
||||
return
|
||||
}
|
||||
prepSnapshot.value = pickData(res) as B2bPackingSnapshot
|
||||
} catch {
|
||||
// 请求层已统一提示错误
|
||||
} finally {
|
||||
prepSnapshotLoading.value = false
|
||||
}
|
||||
}
|
||||
|
||||
/** 备货窗口「保存分箱」:order.updateB2bPackingItems(整单全量替换)后刷新快照 */
|
||||
async function savePrepPacking(payload: B2bPackingPayload) {
|
||||
if (b2bActionLoading.value) return false
|
||||
if (packingSaving.value) {
|
||||
ElMessage.warning('分箱正在自动保存,请稍候再手动保存')
|
||||
return false
|
||||
}
|
||||
const id = toOrderId(prepRow.value?.id ?? prepRow.value?.order_id)
|
||||
if (id === null) {
|
||||
ElMessage.error('所选订单缺少有效订单 ID,请刷新后重试')
|
||||
return false
|
||||
}
|
||||
const ok = await run(
|
||||
() => orderPendingOrderUpdateB2bPackingItems({ ids: [id], items: payload.items }),
|
||||
(data) => {
|
||||
const operator = String(data.prep_operator_name ?? data.prep_operator_id ?? '').trim()
|
||||
const idempotent = Array.isArray(data.idempotent_order_ids) ? data.idempotent_order_ids.length : 0
|
||||
const parts = [`已开始备货${operator ? `(备货人 ${operator})` : ''}`]
|
||||
if (idempotent) parts.push(`其中 ${idempotent} 单为重复开始,保留首次开始时间`)
|
||||
return { text: parts.join(','), warning: idempotent > 0 }
|
||||
const itemCount = Number(data.item_count ?? payload.items.length)
|
||||
const boxCount = Number(data.box_count ?? 0)
|
||||
return { text: `分箱已保存:${itemCount} 条明细 / ${boxCount} 个箱号` }
|
||||
}
|
||||
)
|
||||
if (ok) await loadPrepSnapshot(id)
|
||||
return ok
|
||||
}
|
||||
|
||||
/**
|
||||
* 备货窗口「静默保存分箱」(自动保存用):
|
||||
* 只提交 order.updateB2bPackingItems,成功不弹提示、不刷新快照
|
||||
* (刷新会重建编辑行,导致输入框焦点/光标丢失),失败仍提示错误
|
||||
*/
|
||||
async function savePrepPackingQuiet(payload: B2bPackingPayload): Promise<boolean> {
|
||||
if (packingSaving.value) return false
|
||||
const id = toOrderId(prepRow.value?.id ?? prepRow.value?.order_id)
|
||||
if (id === null) return false
|
||||
packingSaving.value = true
|
||||
try {
|
||||
const res: any = await orderPendingOrderUpdateB2bPackingItems({
|
||||
ids: [id],
|
||||
items: payload.items
|
||||
})
|
||||
if (!isOkCode(res)) {
|
||||
ElMessage.error(res?.message || '分箱保存失败')
|
||||
return false
|
||||
}
|
||||
return true
|
||||
} catch {
|
||||
// 请求层已统一提示错误
|
||||
return false
|
||||
} finally {
|
||||
packingSaving.value = false
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 备货窗口「确认备货完成」:
|
||||
* 1) 有备货照片时先 order.updateB2bOrderImages(全量覆盖)
|
||||
* 2) order.finishB2bPrep 写备注 / 总箱数(完成即扣减库存)
|
||||
* 3) 成功后关闭窗口(不再询问取消备货)
|
||||
* 失败时若返回 data.item_mismatches(齐套校验),把不齐套商品提示出来
|
||||
*/
|
||||
async function submitPrepFinish(payload: B2bPrepFinishSubmitPayload) {
|
||||
if (b2bActionLoading.value) return false
|
||||
const id = toOrderId(prepRow.value?.id ?? prepRow.value?.order_id)
|
||||
if (id === null) {
|
||||
ElMessage.error('所选订单缺少有效订单 ID,请刷新后重试')
|
||||
return false
|
||||
}
|
||||
|
||||
b2bActionLoading.value = true
|
||||
try {
|
||||
const fileIds = payload.file_ids.filter((fileId, index, arr) => arr.indexOf(fileId) === index)
|
||||
if (fileIds.length) {
|
||||
const imagesRes: any = await orderPendingOrderUpdateB2bOrderImages({
|
||||
ids: [id],
|
||||
images: fileIds.map((fileId, index) => ({ file_id: fileId, display_order: index }))
|
||||
})
|
||||
if (!isOkCode(imagesRes)) {
|
||||
ElMessage.error(imagesRes?.message || '保存备货照片失败')
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
||||
const res: any = await orderPendingOrderFinishB2bPrep({
|
||||
ids: [id],
|
||||
prep_remark: payload.prep_remark,
|
||||
total_box_count: payload.total_box_count
|
||||
})
|
||||
if (!isOkCode(res)) {
|
||||
const mismatchText = buildPrepMismatchText(res)
|
||||
ElMessage.error(mismatchText || res?.message || '备货完成失败')
|
||||
// 齐套校验失败后刷新快照,让窗口内的应拣/已分箱与后端一致
|
||||
if (mismatchText) await loadPrepSnapshot(id)
|
||||
return false
|
||||
}
|
||||
|
||||
const data = pickData(res)
|
||||
const boxCount = Number(data.total_box_count ?? payload.total_box_count)
|
||||
const deducted = Number(data.stock_deducted_quantity ?? 0)
|
||||
const duration = Number(data.prep_duration_seconds ?? 0)
|
||||
const parts = [`备货完成:总箱数 ${boxCount}`]
|
||||
if (duration > 0) parts.push(`用时 ${duration} 秒`)
|
||||
if (deducted > 0) parts.push(`扣减库存 ${deducted}`)
|
||||
ElMessage.success(parts.join(','))
|
||||
|
||||
options.onSuccess?.()
|
||||
finishPrepDialogClosed()
|
||||
return true
|
||||
} catch {
|
||||
// 请求层已统一提示错误
|
||||
return false
|
||||
} finally {
|
||||
b2bActionLoading.value = false
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 关闭备货窗口(X / 关闭按钮 / ESC / 点击遮罩 统一走这里):
|
||||
* 先提示「关闭将取消备货」,确认后调用 order.cancelB2bPrep(换人作业),再关闭窗口;
|
||||
* 选择「继续备货」则保持窗口与备货状态不变。
|
||||
*/
|
||||
async function closePrepDialog() {
|
||||
if (prepStarting.value || prepClosing.value) return
|
||||
const row = prepRow.value
|
||||
const id = toOrderId(row?.id ?? row?.order_id)
|
||||
|
||||
if (id === null) {
|
||||
prepDialogVisible.value = false
|
||||
prepRow.value = null
|
||||
prepInfo.value = null
|
||||
prepActivated.value = false
|
||||
return
|
||||
}
|
||||
|
||||
prepClosing.value = true
|
||||
try {
|
||||
await ElMessageBox.confirm(
|
||||
'关闭备货窗口将取消本次备货,取消后可由其他工号重新开始备货。是否继续?',
|
||||
'取消备货',
|
||||
{
|
||||
type: 'warning',
|
||||
buttonSize: 'small',
|
||||
distinguishCancelAndClose: true,
|
||||
confirmButtonText: '取消备货并关闭',
|
||||
cancelButtonText: '继续备货'
|
||||
}
|
||||
)
|
||||
} catch {
|
||||
// 「继续备货」或关闭提示框:保持窗口打开、备货状态不变
|
||||
return
|
||||
} finally {
|
||||
prepClosing.value = false
|
||||
}
|
||||
|
||||
const activated = prepActivated.value
|
||||
prepDialogVisible.value = false
|
||||
prepRow.value = null
|
||||
prepInfo.value = null
|
||||
prepSnapshot.value = null
|
||||
prepActivated.value = false
|
||||
|
||||
if (!activated) return
|
||||
|
||||
b2bActionLoading.value = true
|
||||
try {
|
||||
const res: any = await orderPendingOrderCancelB2bPrep({ ids: [id] })
|
||||
if (!isOkCode(res)) {
|
||||
ElMessage.error(res?.message || '取消备货失败')
|
||||
return
|
||||
}
|
||||
ElMessage.success('已取消备货,可换人重新开始')
|
||||
options.onSuccess?.()
|
||||
} catch {
|
||||
// 请求层已统一提示错误
|
||||
} finally {
|
||||
b2bActionLoading.value = false
|
||||
}
|
||||
}
|
||||
|
||||
/** 备货完成后关闭备货窗口(无需再询问取消备货) */
|
||||
function finishPrepDialogClosed() {
|
||||
prepDialogVisible.value = false
|
||||
prepRow.value = null
|
||||
prepInfo.value = null
|
||||
prepSnapshot.value = null
|
||||
prepActivated.value = false
|
||||
}
|
||||
|
||||
/** order.cancelB2bPrep:取消备货(重置状态并清空备货人 / 时间,需同一备货工号) */
|
||||
@ -188,9 +504,9 @@ export function useB2bActions(options: UseB2bActionsOptions) {
|
||||
)
|
||||
}
|
||||
|
||||
/** order.finishB2bPrep:备货完成(需弹窗填写备货备注与总箱数) */
|
||||
function openFinishPrepDialog() {
|
||||
const target = requireSingleRow('备货完成')
|
||||
/** order.finishB2bPrep:备货完成(需弹窗填写备货备注与总箱数;可传行内订单,否则取勾选行) */
|
||||
function openFinishPrepDialog(row?: any) {
|
||||
const target = row ? { row } : requireSingleRow('备货完成')
|
||||
if (!target) return
|
||||
finishPrepRow.value = target.row
|
||||
finishPrepDialogVisible.value = true
|
||||
@ -208,43 +524,197 @@ export function useB2bActions(options: UseB2bActionsOptions) {
|
||||
ElMessage.error('所选订单缺少有效订单 ID,请刷新后重试')
|
||||
return
|
||||
}
|
||||
const ok = await run(
|
||||
() =>
|
||||
orderPendingOrderFinishB2bPrep({
|
||||
ids: [id],
|
||||
prep_remark: payload.prep_remark,
|
||||
total_box_count: payload.total_box_count
|
||||
}),
|
||||
(data) => {
|
||||
const boxCount = Number(data.total_box_count ?? payload.total_box_count)
|
||||
const deducted = Number(data.stock_deducted_quantity ?? 0)
|
||||
return {
|
||||
text: `备货完成:总箱数 ${boxCount}${deducted > 0 ? `,同步扣减库存 ${deducted}` : ''}`
|
||||
}
|
||||
if (b2bActionLoading.value) return
|
||||
b2bActionLoading.value = true
|
||||
try {
|
||||
const res: any = await orderPendingOrderFinishB2bPrep({
|
||||
ids: [id],
|
||||
prep_remark: payload.prep_remark,
|
||||
total_box_count: payload.total_box_count
|
||||
})
|
||||
if (!isOkCode(res)) {
|
||||
ElMessage.error(buildPrepMismatchText(res) || res?.message || '备货完成失败')
|
||||
return
|
||||
}
|
||||
)
|
||||
if (ok) closeFinishPrepDialog()
|
||||
const data = pickData(res)
|
||||
const boxCount = Number(data.total_box_count ?? payload.total_box_count)
|
||||
const deducted = Number(data.stock_deducted_quantity ?? 0)
|
||||
ElMessage.success(`备货完成:总箱数 ${boxCount}${deducted > 0 ? `,同步扣减库存 ${deducted}` : ''}`)
|
||||
closeFinishPrepDialog()
|
||||
finishPrepDialogClosed()
|
||||
options.onSuccess?.()
|
||||
} catch {
|
||||
// 请求层已统一提示错误
|
||||
} finally {
|
||||
b2bActionLoading.value = false
|
||||
}
|
||||
}
|
||||
|
||||
/** order.pickupB2b:提货(要求备货已完成,重复提货幂等) */
|
||||
async function handlePickup() {
|
||||
const target = requireSingleRow('确认提货')
|
||||
/**
|
||||
* order.pickupB2b:提货弹窗(车牌 + 照片一次性提交,重复提货幂等)
|
||||
* - 传 row 用于行内「确认提货」;不传则取工具栏勾选的单条订单
|
||||
*/
|
||||
function openPickupDialog(row?: any) {
|
||||
const target = row ? { row } : requireSingleRow('确认提货')
|
||||
if (!target) return
|
||||
const ok = await confirm(
|
||||
`确定订单 ${resolveRowLabel(target.row)} 已提货吗?\n要求备货已完成;提货时间记为提交时刻。`,
|
||||
'确认提货',
|
||||
'info'
|
||||
)
|
||||
if (!ok) return
|
||||
await run(
|
||||
() => orderPendingOrderPickupB2b({ ids: [target.id] }),
|
||||
(data) => {
|
||||
if (data.already_picked_up) {
|
||||
return { text: `该订单已于 ${String(data.picked_up_at ?? '')} 提货(重复提交未改写时间)`, warning: true }
|
||||
const orderId = toOrderId(target.row?.id ?? target.row?.order_id)
|
||||
if (orderId === null) {
|
||||
ElMessage.error('所选订单缺少有效订单 ID,请刷新后重试')
|
||||
return
|
||||
}
|
||||
if (String(target.row?.status ?? '').trim().toLowerCase() === 'cancel') {
|
||||
ElMessage.warning('该订单已取消,不允许提货')
|
||||
return
|
||||
}
|
||||
if (String(target.row?.prep_status ?? '').trim().toLowerCase() !== 'fin') {
|
||||
ElMessage.warning('该订单备货未完成,不允许提货')
|
||||
return
|
||||
}
|
||||
pickupRow.value = target.row
|
||||
pickupDialogVisible.value = true
|
||||
}
|
||||
|
||||
function closePickupDialog() {
|
||||
pickupDialogVisible.value = false
|
||||
pickupRow.value = null
|
||||
}
|
||||
|
||||
/**
|
||||
* 提交提货:车牌与照片随 order.pickupB2b 一起提交(提货即出库完成)。
|
||||
* - 车牌有变化才提交:非空 → pickup_plate_number;被清空(原值非空)→ 先 order.setB2bPickupPlate(null)
|
||||
* - 已提货订单车牌已锁定:车牌有变化时直接拦截(后端也会返回 400)
|
||||
* - 照片:pickup_file_ids(追加语义,不覆盖已有提货照片)
|
||||
*/
|
||||
async function submitPickup(payload: B2bPickupPayload) {
|
||||
if (b2bActionLoading.value) return false
|
||||
const row = pickupRow.value
|
||||
const id = toOrderId(row?.id ?? row?.order_id)
|
||||
if (id === null) {
|
||||
ElMessage.error('所选订单缺少有效订单 ID,请刷新后重试')
|
||||
return false
|
||||
}
|
||||
|
||||
const nextPlate = normalizePlate(payload.pickup_plate_number)
|
||||
const currentPlate = normalizePlate(row?.pickup_plate_number)
|
||||
const alreadyPickedUp = String(row?.is_picked_up ?? '').trim().toUpperCase() === 'Y'
|
||||
const plateChanged = nextPlate !== currentPlate
|
||||
if (plateChanged && alreadyPickedUp) {
|
||||
ElMessage.warning('该订单已提货,提货车牌已锁定,不允许修改')
|
||||
return false
|
||||
}
|
||||
const clearPlate = plateChanged && !nextPlate && !!currentPlate
|
||||
const fileIds = payload.file_ids.filter((fileId, index, arr) => arr.indexOf(fileId) === index)
|
||||
|
||||
b2bActionLoading.value = true
|
||||
try {
|
||||
if (clearPlate) {
|
||||
const plateRes: any = await orderPendingOrderSetB2bPickupPlate({
|
||||
ids: [id],
|
||||
pickup_plate_number: null
|
||||
})
|
||||
if (!isOkCode(plateRes)) {
|
||||
ElMessage.error(plateRes?.message || '清空提货车牌失败')
|
||||
return false
|
||||
}
|
||||
return { text: `已记录提货时间:${String(data.picked_up_at ?? '')}` }
|
||||
}
|
||||
|
||||
const pickupRes: any = await orderPendingOrderPickupB2b({
|
||||
ids: [id],
|
||||
...(nextPlate && plateChanged ? { pickup_plate_number: nextPlate } : {}),
|
||||
...(fileIds.length ? { pickup_file_ids: fileIds } : {})
|
||||
})
|
||||
if (!isOkCode(pickupRes)) {
|
||||
ElMessage.error(pickupRes?.message || '提货失败')
|
||||
options.onSuccess?.()
|
||||
return false
|
||||
}
|
||||
|
||||
const data = pickData(pickupRes)
|
||||
const plate = String(data.pickup_plate_number ?? nextPlate ?? '').trim()
|
||||
const imageCount = Number(
|
||||
data.pickup_image_count ?? (Array.isArray(data.pickup_images) ? data.pickup_images.length : 0)
|
||||
)
|
||||
const extras = [
|
||||
plate ? `车牌 ${plate}` : '',
|
||||
imageCount > 0 ? `提货照片 ${imageCount} 张` : '',
|
||||
// 提货即出库完成:主表 outbound_status=fin / step=4,随后由调度迁移到配送表
|
||||
data.outbound_marked === false ? '出库状态此前已完成' : '已标记出库完成'
|
||||
].filter(Boolean)
|
||||
const suffix = extras.length ? `(${extras.join(',')})` : ''
|
||||
|
||||
if (data.already_picked_up) {
|
||||
ElMessage.warning(`该订单已于 ${String(data.picked_up_at ?? '')} 提货,本次仅追加提货信息${suffix}`)
|
||||
} else {
|
||||
ElMessage.success(
|
||||
`提货完成:${String(data.picked_up_at ?? '')}${suffix},稍后可在「配送B2B订单」查看`
|
||||
)
|
||||
}
|
||||
options.onSuccess?.()
|
||||
closePickupDialog()
|
||||
return true
|
||||
} catch {
|
||||
// 请求层已统一提示错误
|
||||
options.onSuccess?.()
|
||||
return false
|
||||
} finally {
|
||||
b2bActionLoading.value = false
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 行内「设置车牌」入口:仅维护提货车牌(order.setB2bPickupPlate)
|
||||
* - 已提货订单:车牌随提货锁定,不再允许修改
|
||||
*/
|
||||
function openPickupPlateDialog(row: any) {
|
||||
const id = toOrderId(row?.id ?? row?.order_id)
|
||||
if (id === null) {
|
||||
ElMessage.error('所选订单缺少有效订单 ID,请刷新后重试')
|
||||
return
|
||||
}
|
||||
if (String(row?.status ?? '').trim().toLowerCase() === 'cancel') {
|
||||
ElMessage.warning('该订单已取消,不允许录入提货车牌')
|
||||
return
|
||||
}
|
||||
if (String(row?.is_picked_up ?? '').trim().toUpperCase() === 'Y') {
|
||||
ElMessage.warning('该订单已提货,提货车牌已锁定,不允许再修改')
|
||||
return
|
||||
}
|
||||
pickupPlateRow.value = row
|
||||
pickupPlateDialogVisible.value = true
|
||||
}
|
||||
|
||||
function closePickupPlateDialog() {
|
||||
pickupPlateDialogVisible.value = false
|
||||
pickupPlateRow.value = null
|
||||
}
|
||||
|
||||
/** 与后端一致:去掉空格与 ·/•/-/-/_ 分隔符后转大写 */
|
||||
function normalizePlate(value: unknown) {
|
||||
return String(value ?? '').replace(/[\s·•\--_]/g, '').toUpperCase()
|
||||
}
|
||||
|
||||
/** order.setB2bPickupPlate:行内录入/修改提货车牌(null 清空) */
|
||||
async function submitPickupPlate(payload: B2bPickupPlatePayload) {
|
||||
const row = pickupPlateRow.value
|
||||
const id = toOrderId(row?.id ?? row?.order_id)
|
||||
if (id === null) {
|
||||
ElMessage.error('所选订单缺少有效订单 ID,请刷新后重试')
|
||||
return
|
||||
}
|
||||
const ok = await run(
|
||||
() =>
|
||||
orderPendingOrderSetB2bPickupPlate({
|
||||
ids: [id],
|
||||
pickup_plate_number: normalizePlate(payload.pickup_plate_number) || null
|
||||
}),
|
||||
(data) => {
|
||||
const plate = String(data.pickup_plate_number ?? '').trim()
|
||||
if (!plate) return { text: '已清空提货车牌' }
|
||||
if (data.changed === false) return { text: `提货车牌未变化(${plate})`, warning: true }
|
||||
return { text: `已录入提货车牌:${plate}` }
|
||||
}
|
||||
)
|
||||
if (ok) closePickupPlateDialog()
|
||||
}
|
||||
|
||||
/** order.setB2bUrgent:批量设为加急(单次最多 200) */
|
||||
@ -290,14 +760,34 @@ export function useB2bActions(options: UseB2bActionsOptions) {
|
||||
|
||||
return {
|
||||
b2bActionLoading,
|
||||
prepDialogVisible,
|
||||
prepRow,
|
||||
prepStarting,
|
||||
prepInfo,
|
||||
prepSnapshot,
|
||||
prepSnapshotLoading,
|
||||
openPrepDialog,
|
||||
closePrepDialog,
|
||||
savePrepPacking,
|
||||
savePrepPackingQuiet,
|
||||
submitPrepFinish,
|
||||
finishPrepDialogClosed,
|
||||
finishPrepDialogVisible,
|
||||
finishPrepRow,
|
||||
submitFinishPrep,
|
||||
closeFinishPrepDialog,
|
||||
handleStartPrep,
|
||||
handleCancelPrep,
|
||||
openFinishPrepDialog,
|
||||
handlePickup,
|
||||
pickupDialogVisible,
|
||||
pickupRow,
|
||||
openPickupDialog,
|
||||
closePickupDialog,
|
||||
submitPickup,
|
||||
pickupPlateDialogVisible,
|
||||
pickupPlateRow,
|
||||
openPickupPlateDialog,
|
||||
closePickupPlateDialog,
|
||||
submitPickupPlate,
|
||||
handleSetUrgent,
|
||||
handleCancelUrgent
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user