oms/frontend/src/api/outboundOrder.ts
liufumingren cc7cd0f107 feat(frontend): 仪表盘报表页、全局统一时间格式化与 UI 紧凑化
- 仪表盘(views/Home.vue 重写):区间切换(近 7/30/90 天)+ 概览指标卡 + 待办提醒
  + 三类单据状态卡(点击跳对应状态列表)+ 两个趋势图 + 库存 Top 商品 + 最近流水;
  新增 api/dashboard.ts;趋势用纯 CSS 柱状条实现,不引入图表库
- 列表页支持仪表盘带筛选跳转:Order/InboundOrder/OutboundOrder 的 Index.vue
  在 onMounted 读取 route.query.status
- 时间统一格式化:新增 utils/datetime.ts(formatDateTime/formatDate),
  各页面时间字段一律走该工具(修正 ISO 串直接展示问题,按本地时区还原挂钟时间)
- UI 紧凑化:App.vue 全局覆盖 Element Plus 内边距到 10px 左右;各页面/组件
  偏大的 padding 收紧,把空间留给内容
- 账号名称/头像:登录注册去昵称、我的页去掉昵称/头像 URL、账号页支持设置名称与头像、
  右上角按头像 → 名称首字符 → 账号首字符降级展示
- 出库单/入库单/发货单列表与创建页:去掉操作人输入、物流公司下拉、推送失败标记等

Co-Authored-By: GitHub Copilot <noreply@github.com>
2026-09-14 16:09:41 +08:00

146 lines
5.8 KiB
TypeScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

import { get, post, put, del } from '@/utils/request'
import type { StockItemLine, StockItemPayload } from './stockOrder'
/** 出库单(单据头) */
export interface OutboundOrder {
id: number
bill_no: string
principal_id: number
shop_id: number | null
outbound_type: string
status: number
customer?: string | null
/** 操作人(审核时系统写入=审核人,接口不可传) */
operator?: string | null
warehouse_id: number | null
warehouse?: { id: number; code: string; name: string } | null
shop?: { id: number; name: string } | null
creator?: { id: number; nickname?: string | null; username: string } | null
item_total: number | string
item_kind: number | null
total_amount: number | string
remark?: string | null
stock_deducted?: number
/** 推送锁定库存标记:1=已锁定(自动推送重试期间保持),0=未锁定/已释放/已扣减 */
stock_locked?: number
/** 运单号集合(WMS 出库确认回传,多包裹时为多个;列名对齐 wms_order_stockout) */
waybill_codes?: string[] | null
/** 快递公司编码(推送 deliveryOrder.logisticsCode,如 SF/STO) */
express_code?: string | null
/** 快递公司名称(按快递公司字典解析的快照) */
express_name?: string | null
/** 收件人(receiverInfo,推送 WMS stockout.create) */
receiver_name?: string | null
receiver_company?: string | null
receiver_tel?: string | null
receiver_mobile?: string | null
receiver_email?: string | null
receiver_country_code?: string | null
receiver_province?: string | null
receiver_city?: string | null
receiver_area?: string | null
receiver_town?: string | null
receiver_detail_address?: string | null
receiver_zip_code?: string | null
receiver_id?: string | null
void_at?: string | null
void_by?: number | null
void_reason?: string | null
voider?: { id: number; nickname?: string | null; username: string } | null
pushed_at?: string | null
wms_push_result?: {
success?: boolean
code?: string | number | null
message?: string | null
error?: string | null
/** 失败类型:business 仓库明确拒绝 / timeout 无响应超时 / insufficient_stock / lock_failed / empty_items */
failureKind?: string
attempts?: number
maxAttempts?: number
retryable?: boolean
deliveryOrderCode?: string | null
pushedAt?: string | null
[key: string]: unknown
} | null
items?: StockItemLine[]
created_at?: string
updated_at?: string
}
/** 明细行(创建时随单提交) */
export interface OutboundItemInput {
product_id?: number | null
name?: string | null
code?: string | null
spec?: string | null
unit?: string | null
quantity?: number
price?: number | null
inventory_type?: 'ZP' | 'CC'
remark?: string | null
}
/** 创建 / 更新载荷 */
export interface OutboundOrderPayload {
warehouse_id?: number | null
shop_id?: number | null
outbound_type?: string
status?: number
customer?: string | null
total_amount?: number
remark?: string | null
/** 快递公司编码(推送为 deliveryOrder.logisticsCode) */
express_code?: string | null
/** 快递公司名称(传编码时前端自动带出) */
express_name?: string | null
receiver_name?: string | null
receiver_company?: string | null
receiver_tel?: string | null
receiver_mobile?: string | null
receiver_email?: string | null
receiver_country_code?: string | null
receiver_province?: string | null
receiver_city?: string | null
receiver_area?: string | null
receiver_town?: string | null
receiver_detail_address?: string | null
receiver_zip_code?: string | null
receiver_id?: string | null
items?: OutboundItemInput[]
}
/** 明细提交(含库存类型 ZP 正品 / CC 残次,与入库单对齐) */
export type OutboundItemPayload = StockItemPayload & { inventory_type?: 'ZP' | 'CC' }
export const outboundOrderApi = {
getList: (params?: object) =>
get<{ list: OutboundOrder[]; total: number; page: number; pageSize: number }>('/outbound-orders', params),
get: (id: number) => get<OutboundOrder>(`/outbound-orders/${id}`),
create: (data: OutboundOrderPayload) => post<{ id: number }>('/outbound-orders', data),
update: (id: number, data: Partial<OutboundOrderPayload>) =>
put<{ id: number }>(`/outbound-orders/${id}`, data),
audit: (id: number) => post<{ id: number; status?: number }>(`/outbound-orders/${id}/audit`),
push: (id: number) => post<{ id: number; attempts?: number }>(`/outbound-orders/${id}/push`),
complete: (id: number) => post<{ id: number }>(`/outbound-orders/${id}/complete`),
cancel: (id: number) => post<{ id: number }>(`/outbound-orders/${id}/cancel`),
restore: (id: number) => post<{ id: number }>(`/outbound-orders/${id}/restore`),
/** 作废:仅「已审核(2)」可作废,记录作废人/时间/原因,不可恢复 */
voidOrder: (id: number, data?: { void_reason?: string }) =>
post<{ id: number }>(`/outbound-orders/${id}/void`, data || {}),
/** 驳回:已审核(2)/已推送(3) 且未完成 -> 回到待出库(1),已推送的先走接口取消外部单据 */
reject: (id: number) => post<{ id: number; bill_no?: string }>(`/outbound-orders/${id}/reject`),
remove: (id: number) => del<{ id: number }>(`/outbound-orders/${id}`),
/** 明细列表(复用通用 stock_items,bill_type=2 出库) */
getItems: (billId: number, params?: object) =>
get<{ list: StockItemLine[]; total: number; page: number; pageSize: number }>('/stock-items', {
bill_id: billId,
bill_type: 2,
...params,
}),
createItem: (data: OutboundItemPayload) =>
post<{ id: number }>('/stock-items', { ...data, bill_type: 2 }),
updateItem: (id: number, data: Partial<OutboundItemPayload>) =>
put<{ id: number }>(`/stock-items/${id}`, data),
removeItem: (id: number) => del<{ id: number }>(`/stock-items/${id}`),
}