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>
This commit is contained in:
parent
489563a4b2
commit
cc7cd0f107
@ -13,4 +13,78 @@ body,
|
||||
height: 100%;
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* 全局紧凑化:把 Element Plus 默认偏大的内边距收到 10px 左右,把空间留给内容
|
||||
* (页面内已有的更细的 scoped 覆盖优先级更高,不受影响)
|
||||
*/
|
||||
:root {
|
||||
--el-main-padding: 10px;
|
||||
--el-card-padding: 10px;
|
||||
--el-dialog-padding-primary: 10px;
|
||||
}
|
||||
|
||||
/* 主内容区 */
|
||||
.el-main {
|
||||
padding: 10px;
|
||||
}
|
||||
|
||||
/* 卡片:头部与内容 */
|
||||
.el-card__header {
|
||||
padding: 10px 12px;
|
||||
}
|
||||
.el-card__body {
|
||||
padding: 10px 12px;
|
||||
}
|
||||
|
||||
/* 弹窗:头/内容/底部 */
|
||||
.el-dialog__header {
|
||||
padding: 10px 12px;
|
||||
margin-right: 0;
|
||||
border-bottom: 1px solid var(--el-border-color-lighter);
|
||||
}
|
||||
.el-dialog__body {
|
||||
padding: 10px 12px;
|
||||
}
|
||||
.el-dialog__footer {
|
||||
padding: 10px 12px;
|
||||
}
|
||||
|
||||
/* 确认框 */
|
||||
.el-message-box {
|
||||
padding: 12px;
|
||||
}
|
||||
.el-message-box__header {
|
||||
padding: 0 0 8px;
|
||||
}
|
||||
.el-message-box__content {
|
||||
padding: 0;
|
||||
}
|
||||
|
||||
/* 表格:单元格上下与左右内边距 */
|
||||
.el-table .cell {
|
||||
padding: 0 8px;
|
||||
}
|
||||
.el-table .el-table__cell {
|
||||
padding: 6px 0;
|
||||
}
|
||||
|
||||
/* 表单:表单项间距 */
|
||||
.el-form-item {
|
||||
margin-bottom: 12px;
|
||||
}
|
||||
|
||||
/* 描述列表:单元格内边距 */
|
||||
.el-descriptions__cell {
|
||||
padding: 8px 10px;
|
||||
}
|
||||
|
||||
/* 抽屉 */
|
||||
.el-drawer__header {
|
||||
margin-bottom: 10px;
|
||||
padding: 10px 12px;
|
||||
}
|
||||
.el-drawer__body {
|
||||
padding: 10px 12px;
|
||||
}
|
||||
</style>
|
||||
|
||||
@ -17,7 +17,7 @@ export interface UserInfo {
|
||||
last_login_at: string | null
|
||||
created_at: string
|
||||
updated_at: string
|
||||
principals?: { id: number; name: string }[]
|
||||
principals?: { id: number; name: string; account_name?: string | null; account_avatar?: string | null }[]
|
||||
}
|
||||
|
||||
export interface RegisterPayload {
|
||||
@ -25,7 +25,6 @@ export interface RegisterPayload {
|
||||
password: string
|
||||
email: string
|
||||
code: string
|
||||
nickname?: string
|
||||
phone?: string
|
||||
}
|
||||
|
||||
|
||||
145
frontend/src/api/dashboard.ts
Normal file
145
frontend/src/api/dashboard.ts
Normal file
@ -0,0 +1,145 @@
|
||||
import { get } from '@/utils/request'
|
||||
|
||||
/**
|
||||
* 仪表盘报表(后端 GET /api/dashboard/report 的只读聚合结果)
|
||||
*
|
||||
* 口径提醒:数量/金额列来自 MySQL DECIMAL / SUM(),可能以字符串返回,展示时统一用 Number() 转换。
|
||||
* 时间字段为 UTC ISO 串,展示统一走 `@/utils/datetime` 的 formatDateTime。
|
||||
*/
|
||||
|
||||
/** 报表区间 */
|
||||
export interface DashboardRange {
|
||||
days: number
|
||||
start_date: string
|
||||
end_date: string
|
||||
}
|
||||
|
||||
/** 概览指标卡 */
|
||||
export interface DashboardOverview {
|
||||
product_count: number
|
||||
shop_count: number
|
||||
warehouse_count: number
|
||||
stock_product_kind: number
|
||||
stock_quantity: number | string
|
||||
stock_available: number | string
|
||||
stock_locked: number | string
|
||||
stock_zc: number | string
|
||||
stock_cc: number | string
|
||||
bill_total: number
|
||||
delivery_count_30d: number
|
||||
delivery_amount_30d: number | string
|
||||
}
|
||||
|
||||
/** 单据状态计数 */
|
||||
export interface DashboardStatusCount {
|
||||
status: number
|
||||
label: string
|
||||
count: number
|
||||
}
|
||||
|
||||
/** 单类单据统计 */
|
||||
export interface DashboardBill {
|
||||
key: 'delivery' | 'inbound' | 'outbound'
|
||||
label: string
|
||||
path: string
|
||||
total: number
|
||||
by_status: DashboardStatusCount[]
|
||||
range_count: number
|
||||
amount: number | string
|
||||
wait_handle: number
|
||||
wait_push: number
|
||||
wait_finish: number
|
||||
finished: number
|
||||
voided: number
|
||||
canceled: number
|
||||
push_fail: number
|
||||
}
|
||||
|
||||
/** 待办项 */
|
||||
export interface DashboardTodo {
|
||||
key: string
|
||||
label: string
|
||||
count: number
|
||||
path: string | null
|
||||
query: Record<string, unknown> | null
|
||||
}
|
||||
|
||||
/** 趋势序列 */
|
||||
export interface DashboardSeries {
|
||||
key: string
|
||||
label: string
|
||||
unit: string
|
||||
values: number[]
|
||||
}
|
||||
|
||||
/** 趋势数据 */
|
||||
export interface DashboardTrend {
|
||||
days: number
|
||||
dates: string[]
|
||||
series: DashboardSeries[]
|
||||
max_bill: number
|
||||
max_qty: number
|
||||
}
|
||||
|
||||
/** 库存 Top 商品 */
|
||||
export interface DashboardTopProduct {
|
||||
product_id: number
|
||||
item_code: string
|
||||
item_name: string
|
||||
sku_property: string
|
||||
stock_unit: string
|
||||
item_type: string
|
||||
quantity: number | string
|
||||
lock_quantity: number | string
|
||||
available: number | string
|
||||
}
|
||||
|
||||
/** 最近出入库流水(字段与 StockRecordItem 一致,仅取展示所需) */
|
||||
export interface DashboardRecord {
|
||||
id: number
|
||||
bill_no: string | null
|
||||
bill_type: number
|
||||
item_name: string | null
|
||||
item_code: string | null
|
||||
item_type: string
|
||||
biz_type: string
|
||||
biz_type_label: string
|
||||
direction: number
|
||||
direction_label: string
|
||||
quantity: number | string
|
||||
quantity_before: number | string
|
||||
quantity_after: number | string
|
||||
available_before: number | string
|
||||
available_after: number | string
|
||||
remark: string | null
|
||||
created_at: string
|
||||
}
|
||||
|
||||
/** 报表数据 */
|
||||
export interface DashboardReport {
|
||||
range: DashboardRange
|
||||
overview: DashboardOverview
|
||||
bills: DashboardBill[]
|
||||
todo: DashboardTodo[]
|
||||
trend: DashboardTrend
|
||||
movement: { inbound_qty: number | string; outbound_qty: number | string }
|
||||
top_products: DashboardTopProduct[]
|
||||
recent_records: DashboardRecord[]
|
||||
}
|
||||
|
||||
/** 查询参数(principal_id 由请求拦截器自动注入) */
|
||||
export interface DashboardParams {
|
||||
/** 趋势区间天数:7/14/30/90,其他值后端按 7 处理 */
|
||||
days?: number
|
||||
/** 仓库ID(仅过滤单据与流水;库存无仓库维度) */
|
||||
warehouse_id?: number
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取仪表盘报表数据(一次返回概览、单据状态、待办、趋势、库存 Top、最近流水)
|
||||
* @param {DashboardParams} [params] 查询参数
|
||||
* @return {Promise<DashboardReport>} 报表数据
|
||||
*/
|
||||
export function getDashboardReport(params?: DashboardParams) {
|
||||
return get<DashboardReport>('/dashboard/report', params)
|
||||
}
|
||||
@ -27,8 +27,11 @@ export interface InboundOrder {
|
||||
logistics_code?: string | null
|
||||
logistics_name?: string | null
|
||||
express_code?: string | null
|
||||
/** 发件人信息(仅本地留存:WMS 入库单报文不识别,不下发) */
|
||||
sender_info?: Record<string, string> | null
|
||||
/** 收件人信息(仅本地留存:WMS 入库单报文不识别,不下发) */
|
||||
receiver_info?: Record<string, string> | null
|
||||
/** 扩展属性(仅本地留存:不下发) */
|
||||
extend_props?: Record<string, string> | null
|
||||
pushed_at?: string | null
|
||||
wms_push_result?: {
|
||||
@ -77,8 +80,6 @@ export interface InboundOrderPayload {
|
||||
status?: number
|
||||
supplier?: string | null
|
||||
supplier_code?: string | null
|
||||
operator?: string | null
|
||||
operator_code?: string | null
|
||||
operate_time?: string | null
|
||||
purchase_order_code?: string | null
|
||||
expect_start_time?: string | null
|
||||
@ -86,9 +87,6 @@ export interface InboundOrderPayload {
|
||||
logistics_code?: string | null
|
||||
logistics_name?: string | null
|
||||
express_code?: string | null
|
||||
sender_info?: unknown
|
||||
receiver_info?: unknown
|
||||
extend_props?: unknown
|
||||
total_amount?: number
|
||||
remark?: string | null
|
||||
items?: InboundItemInput[]
|
||||
|
||||
@ -14,7 +14,6 @@ export interface OrderDeliveryLine {
|
||||
retail_price: number | string | null
|
||||
ext_code: string | null
|
||||
inventory_type: string
|
||||
owner_code: string | null
|
||||
source_order_code: string | null
|
||||
sub_source_order_code: string | null
|
||||
stock_id: number | null
|
||||
@ -33,7 +32,6 @@ export interface OrderDeliveryLineInput {
|
||||
retail_price?: number | null
|
||||
ext_code?: string | null
|
||||
inventory_type?: 'ZP' | 'CC'
|
||||
owner_code?: string | null
|
||||
source_order_code?: string | null
|
||||
sub_source_order_code?: string | null
|
||||
stock_id?: number | null
|
||||
@ -148,6 +146,7 @@ export interface OrderDeliveryPayload {
|
||||
got_amount?: number | null
|
||||
logistics_code?: string | null
|
||||
logistics_name?: string | null
|
||||
/** ERP 审核人(operatorName,审核时系统写入=审核人在本主体下的账号名称) */
|
||||
operator_name?: string | null
|
||||
oaid_order_source_code?: string | null
|
||||
source_order_codes?: string | null
|
||||
|
||||
@ -10,6 +10,7 @@ export interface OutboundOrder {
|
||||
outbound_type: string
|
||||
status: number
|
||||
customer?: string | null
|
||||
/** 操作人(审核时系统写入=审核人,接口不可传) */
|
||||
operator?: string | null
|
||||
warehouse_id: number | null
|
||||
warehouse?: { id: number; code: string; name: string } | null
|
||||
@ -20,6 +21,8 @@ export interface OutboundOrder {
|
||||
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) */
|
||||
@ -50,6 +53,11 @@ export interface OutboundOrder {
|
||||
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
|
||||
@ -79,7 +87,6 @@ export interface OutboundOrderPayload {
|
||||
outbound_type?: string
|
||||
status?: number
|
||||
customer?: string | null
|
||||
operator?: string | null
|
||||
total_amount?: number
|
||||
remark?: string | null
|
||||
/** 快递公司编码(推送为 deliveryOrder.logisticsCode) */
|
||||
@ -112,8 +119,8 @@ export const outboundOrderApi = {
|
||||
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 }>(`/outbound-orders/${id}/audit`),
|
||||
push: (id: number) => post<{ id: number }>(`/outbound-orders/${id}/push`),
|
||||
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`),
|
||||
|
||||
@ -4,6 +4,10 @@ export interface PrincipalUserItem {
|
||||
id: number
|
||||
principal_id: number
|
||||
user_id: number
|
||||
/** 该账号在此主体下的显示名称(推送单据操作人取此值) */
|
||||
name: string | null
|
||||
/** 该账号在此主体下的头像 URL */
|
||||
avatar: string | null
|
||||
role: string | null
|
||||
is_default: number
|
||||
status: number
|
||||
@ -34,12 +38,15 @@ export function getPrincipalUsers(params?: object) {
|
||||
}
|
||||
|
||||
/** 邀请开通主体账号:创建新用户(随机初始密码)并绑定到当前主体 */
|
||||
export function invitePrincipalUser(data: { email: string; name: string }) {
|
||||
export function invitePrincipalUser(data: { email: string; name: string; avatar?: string | null }) {
|
||||
return post<InviteResult>('/principal-users/invite', data)
|
||||
}
|
||||
|
||||
/** 更新关联(角色 / 状态) */
|
||||
export function updatePrincipalUser(id: number, data: { role?: string; status?: number }) {
|
||||
/** 更新关联(名称 / 头像 / 角色 / 状态) */
|
||||
export function updatePrincipalUser(
|
||||
id: number,
|
||||
data: { name?: string; avatar?: string | null; role?: string; status?: number },
|
||||
) {
|
||||
return put<{ id: number }>(`/principal-users/${id}`, data)
|
||||
}
|
||||
|
||||
|
||||
@ -224,9 +224,9 @@ function pickProduct(row: ProductItem) {
|
||||
}
|
||||
/* 弹窗(append-to-body 仍带组件 scope 属性,可用 :deep 命中) */
|
||||
.product-select :deep(.el-dialog__header) {
|
||||
padding: 12px 16px;
|
||||
padding: 10px 12px;
|
||||
}
|
||||
.product-select :deep(.el-dialog__body) {
|
||||
padding: 4px 16px 14px;
|
||||
padding: 4px 12px 10px;
|
||||
}
|
||||
</style>
|
||||
|
||||
@ -188,7 +188,7 @@ const rowEventHandlers = {
|
||||
}
|
||||
|
||||
.virtual-table__empty {
|
||||
padding: 24px 0;
|
||||
padding: 12px 0;
|
||||
font-size: 12px;
|
||||
color: var(--el-text-color-secondary);
|
||||
text-align: center;
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
<script setup lang="ts">
|
||||
import { onMounted } from 'vue'
|
||||
import { computed, onMounted } from 'vue'
|
||||
import { RouterView, useRouter } from 'vue-router'
|
||||
import { ElMessageBox } from 'element-plus'
|
||||
import { ArrowDown } from '@element-plus/icons-vue'
|
||||
@ -13,6 +13,19 @@ const menuStore = useMenuStore()
|
||||
const principalStore = usePrincipalStore()
|
||||
const router = useRouter()
|
||||
|
||||
/**
|
||||
* 当前账号在当前主体下的名称与头像(来自主体账号关联表 principal_users.name / avatar)。
|
||||
* 回退顺序:关联名称 → 全局昵称 → 登录账号;无头像时顶栏显示名称首字符(支持中文)。
|
||||
*/
|
||||
const accountProfile = computed(() => {
|
||||
const user = auth.user
|
||||
const currentId = principalStore.currentId
|
||||
const relation = (user?.principals || []).find(p => Number(p.id) === Number(currentId))
|
||||
const name = relation?.account_name || user?.nickname || user?.username || ''
|
||||
const avatar = relation?.account_avatar || ''
|
||||
return { name, avatar, initial: name ? Array.from(name.trim())[0] || '' : '' }
|
||||
})
|
||||
|
||||
onMounted(() => {
|
||||
// 当前主体若已不在所属列表内(如切换账号),重置为第一个
|
||||
const ids = (auth.user?.principals || []).map((p) => p.id)
|
||||
@ -67,7 +80,10 @@ function onPrincipalChange(id: number) {
|
||||
</el-select>
|
||||
<el-dropdown v-if="auth.user">
|
||||
<span class="user-name">
|
||||
{{ auth.user.nickname || auth.user.username }}
|
||||
<el-avatar :size="28" :src="accountProfile.avatar || undefined">
|
||||
{{ accountProfile.initial }}
|
||||
</el-avatar>
|
||||
<span class="user-name-text">{{ accountProfile.name || '未命名账号' }}</span>
|
||||
<el-icon><ArrowDown /></el-icon>
|
||||
</span>
|
||||
<template #dropdown>
|
||||
@ -118,7 +134,7 @@ function onPrincipalChange(id: number) {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: flex-end;
|
||||
padding: 0 24px;
|
||||
padding: 0 12px;
|
||||
background-color: #fff;
|
||||
border-bottom: 1px solid var(--el-border-color);
|
||||
}
|
||||
@ -142,6 +158,20 @@ function onPrincipalChange(id: number) {
|
||||
color: var(--el-text-color-primary);
|
||||
}
|
||||
|
||||
/* 无头像时 el-avatar 以插槽文本(名称首字符)展示 */
|
||||
.user-name :deep(.el-avatar) {
|
||||
flex-shrink: 0;
|
||||
font-size: 13px;
|
||||
}
|
||||
|
||||
.user-name-text {
|
||||
margin-left: 4px;
|
||||
max-width: 160px;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
.app-main {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
|
||||
82
frontend/src/utils/datetime.ts
Normal file
82
frontend/src/utils/datetime.ts
Normal file
@ -0,0 +1,82 @@
|
||||
/**
|
||||
* 时间格式化工具:前端统一展示口径 `YYYY-MM-DD HH:mm:ss`。
|
||||
*
|
||||
* 背景:后端 Sequelize 的 timezone 为 `+08:00`,DATETIME 落库的是**东八区挂钟时间**
|
||||
* (例:库里 `2026-09-14 01:35:35`),而 JSON 序列化会输出 UTC 的 ISO 串
|
||||
* (接口返回 `2026-09-13T17:35:35.000Z`)。若页面直接渲染,用户看到的就是这串 ISO。
|
||||
* 因此这里统一用**浏览器本地时区**把它还原成挂钟时间,保证看到的与库里一致。
|
||||
*
|
||||
* 兼容的输入:
|
||||
* - ISO 串(带 Z 或 ±HH:mm 偏移)→ 按本地时区换算后格式化
|
||||
* - `YYYY-MM-DD HH:mm(:ss)` / `YYYY-MM-DDTHH:mm(:ss)`(无时区信息,如 el-date-picker 的 value-format)
|
||||
* → 视为本地挂钟时间,原样归一化(补秒、T 换空格),不做时区换算
|
||||
* - 时间戳数字(10 位按秒、13 位按毫秒)、Date 对象
|
||||
* - 空值(null/undefined/空串)→ 返回 fallback(默认 `-`)
|
||||
* - 无法解析的字符串 → 原样返回,避免把有效信息吞掉
|
||||
*/
|
||||
|
||||
/** 已含日期、可选时间的“无时区”字符串 */
|
||||
const PLAIN_RE = /^\d{4}-\d{2}-\d{2}([ T]\d{2}:\d{2}(:\d{2})?(\.\d+)?)?$/;
|
||||
/** 带时区标识(Z / +08:00 / +0800) */
|
||||
const TZ_RE = /([zZ]|[+-]\d{2}:?\d{2})$/;
|
||||
|
||||
export type DateInput = string | number | Date | null | undefined;
|
||||
|
||||
const pad2 = (n: number): string => String(n).padStart(2, '0');
|
||||
|
||||
/** 把无时区的挂钟时间字符串归一化为 `YYYY-MM-DD HH:mm:ss` */
|
||||
function normalizePlain(text: string): string {
|
||||
const [ datePart, timePart = '' ] = text.replace('T', ' ').split(' ');
|
||||
const [ hh = '00', mm = '00', ss = '00' ] = timePart.split(':');
|
||||
return `${datePart} ${pad2(Number(hh))}:${pad2(Number(mm))}:${pad2(Number(ss.split('.')[0] || 0))}`;
|
||||
}
|
||||
|
||||
/** 解析为 Date;不可解析返回 null */
|
||||
function toDate(value: DateInput): Date | null {
|
||||
if (value == null || value === '') return null;
|
||||
if (value instanceof Date) return Number.isNaN(value.getTime()) ? null : value;
|
||||
if (typeof value === 'number') {
|
||||
const ms = Math.abs(value) < 1e12 ? value * 1000 : value; // 10 位时间戳按秒
|
||||
const d = new Date(ms);
|
||||
return Number.isNaN(d.getTime()) ? null : d;
|
||||
}
|
||||
const text = String(value).trim();
|
||||
if (!text) return null;
|
||||
const d = new Date(text);
|
||||
return Number.isNaN(d.getTime()) ? null : d;
|
||||
}
|
||||
|
||||
/**
|
||||
* 格式化为 `YYYY-MM-DD HH:mm:ss`
|
||||
* @param {DateInput} value 时间值
|
||||
* @param {string} [fallback] 空值兜底文案,默认 `-`
|
||||
* @return {string} 格式化结果
|
||||
*/
|
||||
export function formatDateTime(value: DateInput, fallback = '-'): string {
|
||||
if (value == null || value === '') return fallback;
|
||||
if (typeof value === 'string') {
|
||||
const text = value.trim();
|
||||
if (!text) return fallback;
|
||||
// 无时区信息的挂钟时间:原样归一化(避免被当成 UTC 再换算一次)
|
||||
if (PLAIN_RE.test(text) && !TZ_RE.test(text)) return normalizePlain(text);
|
||||
}
|
||||
const d = toDate(value);
|
||||
if (!d) return typeof value === 'string' && value.trim() ? value.trim() : fallback;
|
||||
return (
|
||||
`${d.getFullYear()}-${pad2(d.getMonth() + 1)}-${pad2(d.getDate())} ` +
|
||||
`${pad2(d.getHours())}:${pad2(d.getMinutes())}:${pad2(d.getSeconds())}`
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* 格式化为 `YYYY-MM-DD`
|
||||
* @param {DateInput} value 时间值
|
||||
* @param {string} [fallback] 空值兜底文案,默认 `-`
|
||||
* @return {string} 格式化结果
|
||||
*/
|
||||
export function formatDate(value: DateInput, fallback = '-'): string {
|
||||
const full = formatDateTime(value, fallback);
|
||||
return full === fallback ? full : full.slice(0, 10);
|
||||
}
|
||||
|
||||
export default { formatDateTime, formatDate };
|
||||
@ -15,6 +15,6 @@ import { ElMessage } from 'element-plus'
|
||||
|
||||
<style scoped>
|
||||
.about {
|
||||
padding: 24px;
|
||||
padding: 10px;
|
||||
}
|
||||
</style>
|
||||
|
||||
@ -396,7 +396,7 @@ onMounted(fetchList)
|
||||
margin-bottom: 16px;
|
||||
}
|
||||
:deep(.el-drawer__body) {
|
||||
padding: 16px;
|
||||
padding: 10px;
|
||||
overflow: hidden;
|
||||
}
|
||||
.combo-editor {
|
||||
@ -407,7 +407,7 @@ onMounted(fetchList)
|
||||
.combo-info {
|
||||
flex: none;
|
||||
width: 320px;
|
||||
padding-right: 16px;
|
||||
padding-right: 10px;
|
||||
border-right: 1px solid var(--el-border-color-lighter);
|
||||
overflow: auto;
|
||||
}
|
||||
|
||||
@ -43,6 +43,7 @@ import DataTable from '@/components/DataTable.vue'
|
||||
import ListPager from '@/components/ListPager.vue'
|
||||
import FieldValueForm from '@/components/FieldValueForm.vue'
|
||||
import { DEFAULT_PAGE_SIZE, useListPage } from '@/composables/useListPage'
|
||||
import { formatDateTime } from '@/utils/datetime'
|
||||
|
||||
/** 仓库自身的类型 */
|
||||
const WAREHOUSE_TYPE_OPTIONS = [
|
||||
@ -919,10 +920,10 @@ onMounted(fetchList)
|
||||
{{ currentWarehouse.status === 1 ? '启用' : '禁用' }}
|
||||
</el-descriptions-item>
|
||||
<el-descriptions-item label="创建时间">
|
||||
{{ currentWarehouse.created_at || '-' }}
|
||||
{{ formatDateTime(currentWarehouse.created_at) }}
|
||||
</el-descriptions-item>
|
||||
<el-descriptions-item label="更新时间">
|
||||
{{ currentWarehouse.updated_at || '-' }}
|
||||
{{ formatDateTime(currentWarehouse.updated_at) }}
|
||||
</el-descriptions-item>
|
||||
<el-descriptions-item label="备注" :span="3">
|
||||
{{ currentWarehouse.remark || '-' }}
|
||||
@ -1073,7 +1074,9 @@ onMounted(fetchList)
|
||||
</el-tag>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column prop="pushed_at" label="推送时间" width="180" />
|
||||
<el-table-column prop="pushed_at" label="推送时间" width="180">
|
||||
<template #default="{ row }">{{ formatDateTime(row.pushed_at) }}</template>
|
||||
</el-table-column>
|
||||
</DataTable>
|
||||
</div>
|
||||
<ListPager
|
||||
@ -1200,7 +1203,9 @@ onMounted(fetchList)
|
||||
<el-table-column prop="duration" label="耗时" width="90">
|
||||
<template #default="{ row }">{{ row.duration }} ms</template>
|
||||
</el-table-column>
|
||||
<el-table-column prop="created_at" label="时间" width="180" />
|
||||
<el-table-column prop="created_at" label="时间" width="180">
|
||||
<template #default="{ row }">{{ formatDateTime(row.created_at) }}</template>
|
||||
</el-table-column>
|
||||
</DataTable>
|
||||
</div>
|
||||
<ListPager
|
||||
@ -1364,7 +1369,7 @@ onMounted(fetchList)
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
overflow: hidden;
|
||||
padding: 12px 16px;
|
||||
padding: 10px 12px;
|
||||
}
|
||||
.page-header {
|
||||
display: flex;
|
||||
|
||||
@ -1,49 +1,543 @@
|
||||
<script setup lang="ts">
|
||||
import { onMounted, ref } from 'vue'
|
||||
import { Check } from '@element-plus/icons-vue'
|
||||
import { computed, onMounted, ref } from 'vue'
|
||||
import { useRouter } from 'vue-router'
|
||||
import { getDashboardReport, type DashboardBill, type DashboardReport } from '@/api/dashboard'
|
||||
import { useAuthStore } from '@/store/auth'
|
||||
import { usePrincipalStore } from '@/store/principal'
|
||||
import { formatDateTime } from '@/utils/datetime'
|
||||
|
||||
/**
|
||||
* 仪表盘(报表)
|
||||
*
|
||||
* 数据来自 GET /api/dashboard/report 一次聚合返回:概览指标、三类单据的状态分布与待办、
|
||||
* 近 N 天趋势(单据量 / 出入库数量)、库存 Top 商品、最近出入库流水。
|
||||
* 不引入图表库:趋势用 CSS 柱状条渲染(含 tooltip 与合计),保持零额外依赖。
|
||||
*/
|
||||
const auth = useAuthStore()
|
||||
const count = ref(0)
|
||||
const inputValue = ref('')
|
||||
const principalStore = usePrincipalStore()
|
||||
const router = useRouter()
|
||||
|
||||
// 进入首页时若已有 token 但尚未加载用户信息,则拉取一次
|
||||
onMounted(async () => {
|
||||
if (auth.token && !auth.user) {
|
||||
try {
|
||||
await auth.fetchProfile()
|
||||
} catch {
|
||||
// 401 等已由拦截器处理
|
||||
}
|
||||
}
|
||||
/** 可选趋势区间(天) */
|
||||
const RANGE_OPTIONS = [
|
||||
{ label: '近 7 天', value: 7 },
|
||||
{ label: '近 30 天', value: 30 },
|
||||
{ label: '近 90 天', value: 90 },
|
||||
]
|
||||
/** 单据量趋势条颜色(按单据类型区分) */
|
||||
const BAR_CLASSES: Record<string, string> = {
|
||||
delivery: 'bar-delivery',
|
||||
inbound: 'bar-inbound',
|
||||
outbound: 'bar-outbound',
|
||||
inbound_qty: 'bar-inbound',
|
||||
outbound_qty: 'bar-outbound',
|
||||
}
|
||||
|
||||
const loading = ref(false)
|
||||
const days = ref(7)
|
||||
const report = ref<DashboardReport | null>(null)
|
||||
|
||||
const overview = computed(() => report.value?.overview || null)
|
||||
/** 当前账号在当前主体下的名称(与右上角头像旁名称同口径) */
|
||||
const accountName = computed(() => {
|
||||
const relation = (auth.user?.principals || []).find((p) => p.id === principalStore.currentId)
|
||||
return relation?.account_name || relation?.name || auth.user?.nickname || auth.user?.username || '当前账号'
|
||||
})
|
||||
/** 单据量趋势序列(发货单/入库单/出库单) */
|
||||
const billSeries = computed(() =>
|
||||
(report.value?.trend.series || []).filter((s) => [ 'delivery', 'inbound', 'outbound' ].includes(s.key)),
|
||||
)
|
||||
/** 出入库数量趋势序列 */
|
||||
const qtySeries = computed(() => (report.value?.trend.series || []).filter((s) => s.key.endsWith('_qty')))
|
||||
/** 待办单据总数(各待办项相加) */
|
||||
const todoTotal = computed(() => (report.value?.todo || []).reduce((sum, item) => sum + item.count, 0))
|
||||
const lastIndex = computed(() => Math.max((report.value?.trend.dates.length || 1) - 1, 0))
|
||||
|
||||
/** 拉取报表数据 */
|
||||
async function fetchReport() {
|
||||
loading.value = true
|
||||
try {
|
||||
report.value = await getDashboardReport({ days: days.value })
|
||||
} catch {
|
||||
// 错误已由响应拦截器统一提示
|
||||
} finally {
|
||||
loading.value = false
|
||||
}
|
||||
}
|
||||
|
||||
/** 数值化(后端 DECIMAL/SUM 可能返回字符串) */
|
||||
function num(value: unknown): number {
|
||||
const n = Number(value ?? 0)
|
||||
return Number.isFinite(n) ? n : 0
|
||||
}
|
||||
|
||||
/** 千分位展示 */
|
||||
function nf(value: unknown, digits = 0): string {
|
||||
return num(value).toLocaleString('zh-CN', { minimumFractionDigits: digits, maximumFractionDigits: digits })
|
||||
}
|
||||
|
||||
/** 趋势条高度(按当前图表最大值归一化,0 保留 2px 底纹便于识别) */
|
||||
function barHeight(value: number, max: number): string {
|
||||
if (!value) return '2px'
|
||||
return `${Math.max(4, Math.round((value / (max || 1)) * 72))}px`
|
||||
}
|
||||
|
||||
/** 序列合计 */
|
||||
function seriesTotal(values: number[]): number {
|
||||
return values.reduce((sum, value) => sum + num(value), 0)
|
||||
}
|
||||
|
||||
/** 跳转到对应列表页(可带筛选条件;列表页会读取 status 初始化筛选) */
|
||||
function goto(path: string | null | undefined, query?: Record<string, unknown> | null) {
|
||||
if (!path) return
|
||||
const textQuery = query
|
||||
? Object.fromEntries(Object.entries(query).map(([ k, v ]) => [ k, String(v) ]))
|
||||
: undefined
|
||||
router.push({ path, query: textQuery })
|
||||
}
|
||||
|
||||
/** 点击状态跳转到该状态的单据列表 */
|
||||
function statusJump(bill: DashboardBill, status: number) {
|
||||
router.push({ path: bill.path, query: { status: String(status) } })
|
||||
}
|
||||
|
||||
onMounted(fetchReport)
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div class="home">
|
||||
<el-card header="欢迎使用 OMS 前端脚手架">
|
||||
<el-space direction="vertical" size="large" fill>
|
||||
<el-alert
|
||||
v-if="auth.user"
|
||||
type="success"
|
||||
:closable="false"
|
||||
:title="`你好,${auth.user.nickname || auth.user.username}!Vue 3 + TypeScript + Element Plus 已就绪`"
|
||||
/>
|
||||
<el-alert v-else type="info" :closable="false" title="当前为游客态,请先登录" />
|
||||
<div v-loading="loading" class="dashboard">
|
||||
<el-card class="dash-card" shadow="never">
|
||||
<div class="dash-head">
|
||||
<div>
|
||||
<el-button type="primary" @click="count++">点击计数: {{ count }}</el-button>
|
||||
<el-button>默认按钮</el-button>
|
||||
<el-button type="success" :icon="Check">成功</el-button>
|
||||
<div class="dash-title">经营看板</div>
|
||||
<div class="dash-sub">
|
||||
{{ accountName }}
|
||||
<template v-if="report"> · 统计区间 {{ report.range.start_date }} ~ {{ report.range.end_date }}</template>
|
||||
</div>
|
||||
</div>
|
||||
<el-input v-model="inputValue" placeholder="请输入内容" style="max-width: 320px" />
|
||||
<span v-if="inputValue">你输入了:{{ inputValue }}</span>
|
||||
</el-space>
|
||||
<div class="dash-actions">
|
||||
<el-radio-group v-model="days" size="small" @change="fetchReport">
|
||||
<el-radio-button v-for="o in RANGE_OPTIONS" :key="o.value" :value="o.value">{{ o.label }}</el-radio-button>
|
||||
</el-radio-group>
|
||||
<el-button size="small" @click="fetchReport">刷新</el-button>
|
||||
</div>
|
||||
</div>
|
||||
</el-card>
|
||||
|
||||
<template v-if="report && overview">
|
||||
<!-- 概览指标 -->
|
||||
<div class="metrics">
|
||||
<div class="metric">
|
||||
<div class="metric-label">商品 / 店铺 / 仓库</div>
|
||||
<div class="metric-value">{{ overview.product_count }} / {{ overview.shop_count }} / {{ overview.warehouse_count }}</div>
|
||||
<div class="metric-extra">系统在用的基础资料数量</div>
|
||||
</div>
|
||||
<div class="metric">
|
||||
<div class="metric-label">库存总量</div>
|
||||
<div class="metric-value">{{ nf(overview.stock_quantity) }}</div>
|
||||
<div class="metric-extra">可用 {{ nf(overview.stock_available) }} · 锁定 {{ nf(overview.stock_locked) }}</div>
|
||||
</div>
|
||||
<div class="metric">
|
||||
<div class="metric-label">正品 / 残次品库存</div>
|
||||
<div class="metric-value">{{ nf(overview.stock_zc) }} / {{ nf(overview.stock_cc) }}</div>
|
||||
<div class="metric-extra">有库存商品 {{ overview.stock_product_kind }} 种</div>
|
||||
</div>
|
||||
<div class="metric">
|
||||
<div class="metric-label">单据总数</div>
|
||||
<div class="metric-value">{{ nf(overview.bill_total) }}</div>
|
||||
<div class="metric-extra">发货单 + 入库单 + 出库单</div>
|
||||
</div>
|
||||
<div class="metric">
|
||||
<div class="metric-label">区间内出入库</div>
|
||||
<div class="metric-value">{{ nf(report.movement.inbound_qty) }} / {{ nf(report.movement.outbound_qty) }}</div>
|
||||
<div class="metric-extra">入库 / 出库数量(按库存流水统计)</div>
|
||||
</div>
|
||||
<div class="metric">
|
||||
<div class="metric-label">近 30 天发货单</div>
|
||||
<div class="metric-value">{{ nf(overview.delivery_count_30d) }}</div>
|
||||
<div class="metric-extra">金额合计 {{ nf(overview.delivery_amount_30d, 2) }}</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- 待办提醒 -->
|
||||
<el-card class="dash-card" shadow="never">
|
||||
<template #header>
|
||||
<div class="card-head">
|
||||
<span>待办提醒</span>
|
||||
<span class="card-sub">{{ report.todo.length }} 项 / 共 {{ todoTotal }} 张单据</span>
|
||||
</div>
|
||||
</template>
|
||||
<div v-if="report.todo.length" class="todo-list">
|
||||
<el-tag
|
||||
v-for="item in report.todo"
|
||||
:key="item.key"
|
||||
class="todo-item"
|
||||
effect="plain"
|
||||
:type="item.key.includes('push_fail') ? 'danger' : 'warning'"
|
||||
@click="goto(item.path, item.query)"
|
||||
>
|
||||
{{ item.label }} · {{ item.count }}
|
||||
</el-tag>
|
||||
</div>
|
||||
<el-empty v-else description="暂无待办" :image-size="56" />
|
||||
</el-card>
|
||||
|
||||
<!-- 单据状态概览 -->
|
||||
<div class="bill-grid">
|
||||
<div v-for="bill in report.bills" :key="bill.key" class="bill-card">
|
||||
<div class="bill-head">
|
||||
<span class="bill-name" @click="goto(bill.path)">{{ bill.label }}</span>
|
||||
<span class="bill-total">{{ nf(bill.total) }} 张</span>
|
||||
</div>
|
||||
<div class="bill-status">
|
||||
<span
|
||||
v-for="s in bill.by_status"
|
||||
:key="s.status"
|
||||
class="status-chip"
|
||||
:class="{ zero: !s.count }"
|
||||
@click="statusJump(bill, s.status)"
|
||||
>
|
||||
<span class="dot" :class="`dot-${s.status}`" />{{ s.label }} {{ s.count }}
|
||||
</span>
|
||||
</div>
|
||||
<div class="bill-foot">
|
||||
<span>区间新增 {{ nf(bill.range_count) }}</span>
|
||||
<span v-if="num(bill.amount)">金额 {{ nf(bill.amount, 2) }}</span>
|
||||
<span v-if="bill.push_fail" class="danger-text">推送失败 {{ bill.push_fail }}</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- 趋势 -->
|
||||
<div class="two-col">
|
||||
<div>
|
||||
<el-card class="dash-card" shadow="never">
|
||||
<template #header>
|
||||
<div class="card-head">
|
||||
<span>近 {{ report.trend.days }} 天单据量</span>
|
||||
<span class="card-sub">按创建时间统计</span>
|
||||
</div>
|
||||
</template>
|
||||
<div class="chart">
|
||||
<div v-for="s in billSeries" :key="s.key" class="chart-row">
|
||||
<span class="chart-label">{{ s.label }}</span>
|
||||
<div class="chart-bars">
|
||||
<el-tooltip
|
||||
v-for="(v, i) in s.values"
|
||||
:key="i"
|
||||
:content="`${report.trend.dates[i]}:${v} ${s.unit}`"
|
||||
placement="top"
|
||||
>
|
||||
<span class="bar" :class="BAR_CLASSES[s.key]" :style="{ height: barHeight(v, report.trend.max_bill) }" />
|
||||
</el-tooltip>
|
||||
</div>
|
||||
<span class="chart-total">{{ seriesTotal(s.values) }}</span>
|
||||
</div>
|
||||
<div class="chart-axis">
|
||||
<span>{{ report.trend.dates[0] }}</span>
|
||||
<span>{{ report.trend.dates[lastIndex] }}</span>
|
||||
</div>
|
||||
</div>
|
||||
</el-card>
|
||||
</div>
|
||||
<div>
|
||||
<el-card class="dash-card" shadow="never">
|
||||
<template #header>
|
||||
<div class="card-head">
|
||||
<span>近 {{ report.trend.days }} 天出入库数量</span>
|
||||
<span class="card-sub">来自库存流水</span>
|
||||
</div>
|
||||
</template>
|
||||
<div class="chart">
|
||||
<div v-for="s in qtySeries" :key="s.key" class="chart-row">
|
||||
<span class="chart-label">{{ s.label }}</span>
|
||||
<div class="chart-bars">
|
||||
<el-tooltip
|
||||
v-for="(v, i) in s.values"
|
||||
:key="i"
|
||||
:content="`${report.trend.dates[i]}:${v} ${s.unit}`"
|
||||
placement="top"
|
||||
>
|
||||
<span class="bar" :class="BAR_CLASSES[s.key]" :style="{ height: barHeight(v, report.trend.max_qty) }" />
|
||||
</el-tooltip>
|
||||
</div>
|
||||
<span class="chart-total">{{ seriesTotal(s.values) }}</span>
|
||||
</div>
|
||||
<div class="chart-axis">
|
||||
<span>{{ report.trend.dates[0] }}</span>
|
||||
<span>{{ report.trend.dates[lastIndex] }}</span>
|
||||
</div>
|
||||
</div>
|
||||
</el-card>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- 库存 Top 商品 + 最近流水 -->
|
||||
<div class="two-col">
|
||||
<div>
|
||||
<el-card class="dash-card" shadow="never">
|
||||
<template #header>
|
||||
<div class="card-head">
|
||||
<span>库存 Top 商品</span>
|
||||
<span class="card-sub">按可用数量倒序</span>
|
||||
</div>
|
||||
</template>
|
||||
<el-table :data="report.top_products" size="small" max-height="240">
|
||||
<el-table-column prop="item_code" label="商品编码" min-width="130" show-overflow-tooltip />
|
||||
<el-table-column prop="item_name" label="商品名称" min-width="130" show-overflow-tooltip />
|
||||
<el-table-column label="类型" width="80">
|
||||
<template #default="{ row }">{{ row.item_type === 'CC' ? '残次品' : '正品' }}</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="可用" width="90" align="right">
|
||||
<template #default="{ row }">{{ nf(row.available) }}</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="锁定" width="90" align="right">
|
||||
<template #default="{ row }">{{ nf(row.lock_quantity) }}</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="总量" width="90" align="right">
|
||||
<template #default="{ row }">{{ nf(row.quantity) }}</template>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
</el-card>
|
||||
</div>
|
||||
<div>
|
||||
<el-card class="dash-card" shadow="never">
|
||||
<template #header>
|
||||
<div class="card-head">
|
||||
<span>最近出入库流水</span>
|
||||
<el-button link type="primary" size="small" @click="goto('/stock-record')">查看全部</el-button>
|
||||
</div>
|
||||
</template>
|
||||
<el-table :data="report.recent_records" size="small" max-height="240">
|
||||
<el-table-column label="记录时间" width="150">
|
||||
<template #default="{ row }">{{ formatDateTime(row.created_at) }}</template>
|
||||
</el-table-column>
|
||||
<el-table-column prop="bill_no" label="单据号" width="110" show-overflow-tooltip />
|
||||
<el-table-column prop="biz_type_label" label="业务动作" min-width="110" show-overflow-tooltip />
|
||||
<el-table-column label="方向" width="80">
|
||||
<template #default="{ row }">
|
||||
<el-tag size="small" effect="plain" :type="row.direction === 1 ? 'success' : 'warning'">
|
||||
{{ row.direction_label }}
|
||||
</el-tag>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="数量" width="90" align="right">
|
||||
<template #default="{ row }">{{ nf(row.quantity) }}</template>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
</el-card>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<el-card v-else-if="!loading" class="dash-card" shadow="never">
|
||||
<el-empty description="暂无报表数据" />
|
||||
</el-card>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<style scoped>
|
||||
.home {
|
||||
padding: 24px;
|
||||
.dashboard {
|
||||
padding: 10px;
|
||||
}
|
||||
|
||||
.dash-card {
|
||||
margin-bottom: 10px;
|
||||
}
|
||||
/* 两栏布局:用网格代替 el-row/el-col,避免 gutter 负外边距引发横向滚动 */
|
||||
.two-col {
|
||||
display: grid;
|
||||
grid-template-columns: 1fr 1fr;
|
||||
gap: 10px;
|
||||
}
|
||||
@media (max-width: 1100px) {
|
||||
.two-col {
|
||||
grid-template-columns: 1fr;
|
||||
}
|
||||
}
|
||||
.dash-card :deep(.el-card__header) {
|
||||
padding: 8px 12px;
|
||||
}
|
||||
|
||||
.dash-head {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
gap: 10px;
|
||||
}
|
||||
.dash-title {
|
||||
font-size: 16px;
|
||||
font-weight: 600;
|
||||
}
|
||||
.dash-sub {
|
||||
margin-top: 4px;
|
||||
font-size: 12px;
|
||||
color: var(--el-text-color-secondary);
|
||||
}
|
||||
.dash-actions {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 8px;
|
||||
}
|
||||
|
||||
.card-head {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
gap: 8px;
|
||||
font-weight: 600;
|
||||
}
|
||||
.card-sub {
|
||||
font-size: 12px;
|
||||
font-weight: 400;
|
||||
color: var(--el-text-color-secondary);
|
||||
}
|
||||
|
||||
/* 概览指标 */
|
||||
.metrics {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
|
||||
gap: 10px;
|
||||
margin-bottom: 10px;
|
||||
}
|
||||
.metric {
|
||||
padding: 10px 12px;
|
||||
background: var(--el-fill-color-lighter);
|
||||
border: 1px solid var(--el-border-color-lighter);
|
||||
border-radius: 4px;
|
||||
}
|
||||
.metric-label {
|
||||
font-size: 12px;
|
||||
color: var(--el-text-color-secondary);
|
||||
}
|
||||
.metric-value {
|
||||
margin: 4px 0 2px;
|
||||
font-size: 20px;
|
||||
font-weight: 600;
|
||||
line-height: 1.2;
|
||||
}
|
||||
.metric-extra {
|
||||
font-size: 12px;
|
||||
color: var(--el-text-color-secondary);
|
||||
}
|
||||
|
||||
/* 待办 */
|
||||
.todo-list {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
gap: 8px;
|
||||
}
|
||||
.todo-item {
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
/* 单据状态 */
|
||||
.bill-grid {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
|
||||
gap: 10px;
|
||||
margin-bottom: 10px;
|
||||
}
|
||||
.bill-card {
|
||||
padding: 10px 12px;
|
||||
background: #fff;
|
||||
border: 1px solid var(--el-border-color-lighter);
|
||||
border-radius: 4px;
|
||||
}
|
||||
.bill-head {
|
||||
display: flex;
|
||||
align-items: baseline;
|
||||
justify-content: space-between;
|
||||
margin-bottom: 8px;
|
||||
}
|
||||
.bill-name {
|
||||
font-weight: 600;
|
||||
cursor: pointer;
|
||||
}
|
||||
.bill-name:hover {
|
||||
color: var(--el-color-primary);
|
||||
}
|
||||
.bill-total {
|
||||
font-size: 12px;
|
||||
color: var(--el-text-color-secondary);
|
||||
}
|
||||
.bill-status {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
gap: 10px;
|
||||
}
|
||||
.status-chip {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
font-size: 12px;
|
||||
cursor: pointer;
|
||||
}
|
||||
.status-chip.zero {
|
||||
color: var(--el-text-color-placeholder);
|
||||
cursor: default;
|
||||
}
|
||||
.dot {
|
||||
width: 6px;
|
||||
height: 6px;
|
||||
margin-right: 4px;
|
||||
border-radius: 50%;
|
||||
background: var(--el-color-info);
|
||||
}
|
||||
.dot-2 { background: var(--el-color-warning); }
|
||||
.dot-3 { background: var(--el-color-primary); }
|
||||
.dot-4 { background: var(--el-color-success); }
|
||||
.dot-5, .dot-9 { background: var(--el-color-danger); }
|
||||
.bill-foot {
|
||||
display: flex;
|
||||
gap: 12px;
|
||||
margin-top: 8px;
|
||||
font-size: 12px;
|
||||
color: var(--el-text-color-secondary);
|
||||
}
|
||||
.danger-text {
|
||||
color: var(--el-color-danger);
|
||||
}
|
||||
|
||||
/* 趋势(纯 CSS 柱状条,不引入图表库) */
|
||||
.chart-row {
|
||||
display: flex;
|
||||
align-items: flex-end;
|
||||
gap: 8px;
|
||||
margin-bottom: 6px;
|
||||
}
|
||||
.chart-label {
|
||||
width: 68px;
|
||||
font-size: 12px;
|
||||
color: var(--el-text-color-secondary);
|
||||
}
|
||||
.chart-bars {
|
||||
display: flex;
|
||||
flex: 1;
|
||||
align-items: flex-end;
|
||||
gap: 2px;
|
||||
height: 76px;
|
||||
border-bottom: 1px solid var(--el-border-color-lighter);
|
||||
}
|
||||
.bar {
|
||||
flex: 1;
|
||||
min-width: 3px;
|
||||
min-height: 2px;
|
||||
background: var(--el-color-primary-light-3);
|
||||
border-radius: 1px;
|
||||
}
|
||||
.bar-delivery { background: var(--el-color-primary-light-3); }
|
||||
.bar-inbound { background: var(--el-color-success-light-3); }
|
||||
.bar-outbound { background: var(--el-color-warning-light-3); }
|
||||
.chart-total {
|
||||
width: 48px;
|
||||
font-size: 12px;
|
||||
text-align: right;
|
||||
color: var(--el-text-color-regular);
|
||||
}
|
||||
.chart-axis {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
padding-left: 76px;
|
||||
font-size: 12px;
|
||||
color: var(--el-text-color-secondary);
|
||||
}
|
||||
</style>
|
||||
|
||||
@ -4,6 +4,7 @@ import { useRouter } from 'vue-router'
|
||||
import { ElMessage, type FormInstance, type FormRules } from 'element-plus'
|
||||
import { inboundOrderApi } from '@/api/inboundOrder'
|
||||
import { getWarehouseOptions, type WarehouseOption } from '@/api/warehouse'
|
||||
import { getExpressCompanyOptions, type ExpressCompanyOption } from '@/api/expressCompany'
|
||||
import type { ProductSearchItem } from '@/api/product'
|
||||
import ProductSelect from '@/components/ProductSelect.vue'
|
||||
import VirtualSelect from '@/components/VirtualSelect.vue'
|
||||
@ -22,20 +23,11 @@ const INVENTORY_TYPE_OPTIONS = [
|
||||
{ label: '正品(ZP)', value: 'ZP' },
|
||||
{ label: '残次(CC)', value: 'CC' },
|
||||
]
|
||||
/** 发件人 / 收件人共用字段(奇门 senderInfo / receiverInfo 子集) */
|
||||
const PARTY_FIELDS: Array<{ key: string; label: string }> = [
|
||||
{ key: 'company', label: '公司' },
|
||||
{ key: 'name', label: '姓名' },
|
||||
{ key: 'mobile', label: '手机' },
|
||||
{ key: 'tel', label: '电话' },
|
||||
{ key: 'province', label: '省' },
|
||||
{ key: 'city', label: '市' },
|
||||
{ key: 'detailAddress', label: '详细地址' },
|
||||
{ key: 'zipCode', label: '邮编' },
|
||||
]
|
||||
|
||||
const router = useRouter()
|
||||
const warehouses = ref<WarehouseOption[]>([])
|
||||
/** 快递公司字典(物流公司下拉选项,不区分主体) */
|
||||
const expressCompanies = ref<ExpressCompanyOption[]>([])
|
||||
|
||||
/* -------------------- 单据信息(页面头部) -------------------- */
|
||||
interface HeaderForm {
|
||||
@ -44,8 +36,6 @@ interface HeaderForm {
|
||||
supplier: string
|
||||
supplier_code: string
|
||||
purchase_order_code: string
|
||||
operator: string
|
||||
operator_code: string
|
||||
express_code: string
|
||||
logistics_code: string
|
||||
logistics_name: string
|
||||
@ -63,8 +53,6 @@ function emptyForm(): HeaderForm {
|
||||
supplier: '',
|
||||
supplier_code: '',
|
||||
purchase_order_code: '',
|
||||
operator: '',
|
||||
operator_code: '',
|
||||
express_code: '',
|
||||
logistics_code: '',
|
||||
logistics_name: '',
|
||||
@ -82,13 +70,11 @@ const rules: FormRules = {
|
||||
warehouse_id: [{ required: true, message: '请选择仓库', trigger: 'change' }],
|
||||
}
|
||||
|
||||
/** WMS 扩展信息(选填,折叠区):发件人 / 收件人 / 扩展属性 */
|
||||
function emptyParty(): Record<string, string> {
|
||||
return Object.fromEntries(PARTY_FIELDS.map(f => [ f.key, '' ]))
|
||||
/** 选择物流公司后带出名称(下拉已展示「名称(编码)」,名称供推送 logisticsName 与列表展示) */
|
||||
function handleExpressChange(code: string | null) {
|
||||
const company = expressCompanies.value.find(c => c.code === code)
|
||||
form.logistics_name = company ? company.name : ''
|
||||
}
|
||||
const senderInfo = reactive(emptyParty())
|
||||
const receiverInfo = reactive(emptyParty())
|
||||
const extendProps = ref<Array<{ key: string; value: string }>>([])
|
||||
|
||||
/* -------------------- 商品明细(内联,随单创建) -------------------- */
|
||||
interface LineItem {
|
||||
@ -133,26 +119,6 @@ const itemsTotal = computed(() =>
|
||||
/* -------------------- 提交 -------------------- */
|
||||
const submitting = ref(false)
|
||||
|
||||
/** 过滤空值:全部为空时返回 null(不下发空对象) */
|
||||
function cleanObject(obj: Record<string, string>) {
|
||||
const r: Record<string, string> = {}
|
||||
let has = false
|
||||
for (const k in obj) {
|
||||
const v = obj[k]
|
||||
if (v != null && String(v).trim() !== '') { r[k] = v; has = true }
|
||||
}
|
||||
return has ? r : null
|
||||
}
|
||||
|
||||
function propsToObject(rows: Array<{ key: string; value: string }>) {
|
||||
const r: Record<string, string> = {}
|
||||
let has = false
|
||||
for (const { key, value } of rows) {
|
||||
if (key && key.trim()) { r[key.trim()] = value; has = true }
|
||||
}
|
||||
return has ? r : null
|
||||
}
|
||||
|
||||
async function submit() {
|
||||
if (!formRef.value) return
|
||||
await formRef.value.validate(async (valid) => {
|
||||
@ -180,8 +146,6 @@ async function submit() {
|
||||
supplier: form.supplier || null,
|
||||
supplier_code: form.supplier_code || null,
|
||||
purchase_order_code: form.purchase_order_code || null,
|
||||
operator: form.operator || null,
|
||||
operator_code: form.operator_code || null,
|
||||
express_code: form.express_code || null,
|
||||
logistics_code: form.logistics_code || null,
|
||||
logistics_name: form.logistics_name || null,
|
||||
@ -190,9 +154,6 @@ async function submit() {
|
||||
expect_end_time: form.expect_end_time || null,
|
||||
total_amount: form.total_amount,
|
||||
remark: form.remark || null,
|
||||
sender_info: cleanObject(senderInfo),
|
||||
receiver_info: cleanObject(receiverInfo),
|
||||
extend_props: propsToObject(extendProps.value),
|
||||
items: lines.value.map(line => ({
|
||||
product_id: line.product_id,
|
||||
name: line.name || null,
|
||||
@ -221,7 +182,12 @@ function cancel() {
|
||||
|
||||
async function fetchOptions() {
|
||||
try {
|
||||
warehouses.value = await getWarehouseOptions()
|
||||
const [ warehouseRes, expressRes ] = await Promise.all([
|
||||
getWarehouseOptions(),
|
||||
getExpressCompanyOptions(),
|
||||
])
|
||||
warehouses.value = warehouseRes
|
||||
expressCompanies.value = expressRes
|
||||
} catch {
|
||||
// 拦截器已提示
|
||||
}
|
||||
@ -284,16 +250,6 @@ onMounted(async () => {
|
||||
<el-input v-model="form.purchase_order_code" placeholder="选填" />
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col :span="6">
|
||||
<el-form-item label="操作人">
|
||||
<el-input v-model="form.operator" placeholder="选填" />
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col :span="6">
|
||||
<el-form-item label="操作员编码">
|
||||
<el-input v-model="form.operator_code" placeholder="选填" />
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col :span="6">
|
||||
<el-form-item label="单据金额">
|
||||
<el-input-number v-model="form.total_amount" :min="0" :precision="2" style="width: 100%" />
|
||||
@ -305,13 +261,17 @@ onMounted(async () => {
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col :span="6">
|
||||
<el-form-item label="物流公司编码">
|
||||
<el-input v-model="form.logistics_code" placeholder="选填,如 SF/YTO" />
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col :span="6">
|
||||
<el-form-item label="物流公司名称">
|
||||
<el-input v-model="form.logistics_name" placeholder="选填" />
|
||||
<el-form-item label="物流公司">
|
||||
<el-select
|
||||
v-model="form.logistics_code"
|
||||
placeholder="选填,推送为 logisticsCode"
|
||||
clearable
|
||||
filterable
|
||||
style="width: 100%"
|
||||
@change="handleExpressChange"
|
||||
>
|
||||
<el-option v-for="c in expressCompanies" :key="c.code" :label="`${c.name}(${c.code})`" :value="c.code" />
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col :span="6">
|
||||
@ -326,7 +286,7 @@ onMounted(async () => {
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col :span="6">
|
||||
<el-form-item label="预期到货(起)">
|
||||
<el-form-item label="预计到货">
|
||||
<el-date-picker
|
||||
v-model="form.expect_start_time"
|
||||
type="datetime"
|
||||
@ -337,7 +297,7 @@ onMounted(async () => {
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col :span="6">
|
||||
<el-form-item label="预期到货(止)">
|
||||
<el-form-item label="最迟到货">
|
||||
<el-date-picker
|
||||
v-model="form.expect_end_time"
|
||||
type="datetime"
|
||||
@ -407,53 +367,6 @@ onMounted(async () => {
|
||||
</template>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
|
||||
<!-- WMS 扩展信息(选填,默认折叠) -->
|
||||
<el-collapse class="ext-collapse">
|
||||
<el-collapse-item title="WMS 扩展信息(选填)" name="ext">
|
||||
<div class="ext-block">
|
||||
<div class="ext-subtitle"><span>发件人(senderInfo)</span></div>
|
||||
<el-row :gutter="12">
|
||||
<el-col v-for="f in PARTY_FIELDS" :key="'s' + f.key" :span="6">
|
||||
<el-form-item :label="f.label" label-width="70px">
|
||||
<el-input v-model="senderInfo[f.key]" />
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
</el-row>
|
||||
</div>
|
||||
|
||||
<div class="ext-block">
|
||||
<div class="ext-subtitle"><span>收件人(receiverInfo)</span></div>
|
||||
<el-row :gutter="12">
|
||||
<el-col v-for="f in PARTY_FIELDS" :key="'r' + f.key" :span="6">
|
||||
<el-form-item :label="f.label" label-width="70px">
|
||||
<el-input v-model="receiverInfo[f.key]" />
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
</el-row>
|
||||
</div>
|
||||
|
||||
<div class="ext-block">
|
||||
<div class="ext-subtitle">
|
||||
<span>扩展属性(extendProps)</span>
|
||||
<el-button size="small" @click="extendProps.push({ key: '', value: '' })">添加</el-button>
|
||||
</div>
|
||||
<el-table :data="extendProps" size="small" border>
|
||||
<el-table-column label="键" width="220">
|
||||
<template #default="{ row }"><el-input v-model="row.key" placeholder="key" /></template>
|
||||
</el-table-column>
|
||||
<el-table-column label="值">
|
||||
<template #default="{ row }"><el-input v-model="row.value" placeholder="value" /></template>
|
||||
</el-table-column>
|
||||
<el-table-column label="" width="64">
|
||||
<template #default="{ $index }">
|
||||
<el-button link type="danger" @click="extendProps.splice($index, 1)">删除</el-button>
|
||||
</template>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
</div>
|
||||
</el-collapse-item>
|
||||
</el-collapse>
|
||||
</el-form>
|
||||
</div>
|
||||
</el-card>
|
||||
@ -532,16 +445,4 @@ onMounted(async () => {
|
||||
font-weight: 600;
|
||||
color: #303133;
|
||||
}
|
||||
.ext-block {
|
||||
margin-bottom: 6px;
|
||||
}
|
||||
.ext-subtitle {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 12px;
|
||||
margin-bottom: 4px;
|
||||
font-size: 13px;
|
||||
font-weight: 600;
|
||||
color: #606266;
|
||||
}
|
||||
</style>
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
<script setup lang="ts">
|
||||
import { computed, onMounted, reactive, ref } from 'vue'
|
||||
import { useRouter } from 'vue-router'
|
||||
import { useRoute, useRouter } from 'vue-router'
|
||||
import { ElMessage, ElMessageBox, type FormInstance, type FormRules } from 'element-plus'
|
||||
import {
|
||||
inboundOrderApi,
|
||||
@ -9,6 +9,7 @@ import {
|
||||
} from '@/api/inboundOrder'
|
||||
import type { StockItemLine } from '@/api/stockOrder'
|
||||
import { getWarehouseOptions, type WarehouseOption } from '@/api/warehouse'
|
||||
import { getExpressCompanyOptions, type ExpressCompanyOption } from '@/api/expressCompany'
|
||||
import { type ProductSearchItem } from '@/api/product'
|
||||
import SplitLayout from '@/components/SplitLayout.vue'
|
||||
import ProductSelect from '@/components/ProductSelect.vue'
|
||||
@ -16,6 +17,7 @@ import DataTable from '@/components/DataTable.vue'
|
||||
import ListPager from '@/components/ListPager.vue'
|
||||
import { DEFAULT_PAGE_SIZE, useListPage } from '@/composables/useListPage'
|
||||
import VirtualSelect from '@/components/VirtualSelect.vue'
|
||||
import { formatDateTime } from '@/utils/datetime'
|
||||
|
||||
const STATUS_LABELS: Record<number, string> = {
|
||||
1: '待入库', 2: '已审核', 3: '已推送', 4: '已完成', 5: '已作废', 9: '已取消',
|
||||
@ -35,18 +37,10 @@ const INV_TYPE_OPTIONS = [
|
||||
{ label: '正品(ZP)', value: 'ZP' },
|
||||
{ label: '残次(CC)', value: 'CC' },
|
||||
]
|
||||
const SENDER_FIELDS: Array<{ key: string; label: string }> = [
|
||||
{ key: 'company', label: '公司' },
|
||||
{ key: 'name', label: '姓名' },
|
||||
{ key: 'mobile', label: '手机' },
|
||||
{ key: 'tel', label: '电话' },
|
||||
{ key: 'province', label: '省' },
|
||||
{ key: 'city', label: '市' },
|
||||
{ key: 'detailAddress', label: '详细地址' },
|
||||
{ key: 'zipCode', label: '邮编' },
|
||||
]
|
||||
|
||||
const warehouses = ref<WarehouseOption[]>([])
|
||||
/** 快递公司字典(物流公司下拉选项,不区分主体) */
|
||||
const expressCompanies = ref<ExpressCompanyOption[]>([])
|
||||
const warehouseSelectOptions = computed(() =>
|
||||
warehouses.value.map((w) => ({ label: `${w.code} ${w.name}`, value: w.id })),
|
||||
)
|
||||
@ -72,6 +66,15 @@ const { loading, list, total, elapsed, fetchList, search, handlePageChange, hand
|
||||
async function fetchWarehouses() {
|
||||
try { warehouses.value = await getWarehouseOptions() } catch { warehouses.value = [] }
|
||||
}
|
||||
/** 快递公司字典(编辑弹窗「物流公司」下拉选项) */
|
||||
async function fetchExpressCompanies() {
|
||||
try { expressCompanies.value = await getExpressCompanyOptions() } catch { expressCompanies.value = [] }
|
||||
}
|
||||
/** 选择物流公司后带出名称(下拉已展示「名称(编码)」,名称供推送 logisticsName 与列表展示) */
|
||||
function handleExpressChange(code: string | null) {
|
||||
const company = expressCompanies.value.find(c => c.code === code)
|
||||
form.logistics_name = company ? company.name : ''
|
||||
}
|
||||
function reset() {
|
||||
query.bill_no = ''
|
||||
query.status = ''
|
||||
@ -96,8 +99,6 @@ const form = reactive({
|
||||
inbound_type: 'CGRK',
|
||||
supplier: '',
|
||||
supplier_code: '',
|
||||
operator: '',
|
||||
operator_code: '',
|
||||
operate_time: '',
|
||||
purchase_order_code: '',
|
||||
logistics_code: '',
|
||||
@ -107,13 +108,11 @@ const form = reactive({
|
||||
expect_end_time: '',
|
||||
total_amount: 0,
|
||||
remark: '',
|
||||
sender_info: { name: '', mobile: '', company: '', province: '', city: '', detailAddress: '' } as Record<string, string>,
|
||||
receiver_info: { name: '', mobile: '', company: '', province: '', city: '', detailAddress: '' } as Record<string, string>,
|
||||
extend_props: [] as Array<{ key: string; value: string }>,
|
||||
})
|
||||
const rules: FormRules = {
|
||||
warehouse_id: [{ required: true, message: '请选择仓库', trigger: 'change' }],
|
||||
}
|
||||
const route = useRoute()
|
||||
const router = useRouter()
|
||||
/** 新增入库单改为独立整页(菜单「创建入库单」),此处仅跳转 */
|
||||
function openCreate() {
|
||||
@ -127,8 +126,6 @@ async function openEdit(row: InboundOrder) {
|
||||
inbound_type: full.inbound_type || 'CGRK',
|
||||
supplier: full.supplier || '',
|
||||
supplier_code: full.supplier_code || '',
|
||||
operator: full.operator || '',
|
||||
operator_code: full.operator_code || '',
|
||||
operate_time: full.operate_time || '',
|
||||
purchase_order_code: full.purchase_order_code || '',
|
||||
logistics_code: full.logistics_code || '',
|
||||
@ -138,32 +135,10 @@ async function openEdit(row: InboundOrder) {
|
||||
expect_end_time: full.expect_end_time || '',
|
||||
total_amount: Number(full.total_amount) || 0,
|
||||
remark: full.remark || '',
|
||||
sender_info: { name: '', mobile: '', company: '', province: '', city: '', detailAddress: '', ...(full.sender_info || {}) },
|
||||
receiver_info: { name: '', mobile: '', company: '', province: '', city: '', detailAddress: '', ...(full.receiver_info || {}) },
|
||||
extend_props: full.extend_props
|
||||
? Object.entries(full.extend_props).map(([key, value]) => ({ key, value: String(value) }))
|
||||
: [],
|
||||
})
|
||||
dialogVisible.value = true
|
||||
}
|
||||
|
||||
function cleanObject(obj: Record<string, string>) {
|
||||
const r: Record<string, string> = {}
|
||||
let has = false
|
||||
for (const k in obj) {
|
||||
const v = obj[k]
|
||||
if (v != null && String(v).trim() !== '') { r[k] = v; has = true }
|
||||
}
|
||||
return has ? r : null
|
||||
}
|
||||
function propsToObject(rows: Array<{ key: string; value: string }>) {
|
||||
const r: Record<string, string> = {}
|
||||
let has = false
|
||||
for (const { key, value } of rows) {
|
||||
if (key && key.trim()) { r[key.trim()] = value; has = true }
|
||||
}
|
||||
return has ? r : null
|
||||
}
|
||||
async function submitForm() {
|
||||
if (!formRef.value) return
|
||||
await formRef.value.validate(async (valid) => {
|
||||
@ -175,8 +150,6 @@ async function submitForm() {
|
||||
inbound_type: form.inbound_type,
|
||||
supplier: form.supplier || null,
|
||||
supplier_code: form.supplier_code || null,
|
||||
operator: form.operator || null,
|
||||
operator_code: form.operator_code || null,
|
||||
operate_time: form.operate_time || null,
|
||||
purchase_order_code: form.purchase_order_code || null,
|
||||
logistics_code: form.logistics_code || null,
|
||||
@ -186,9 +159,6 @@ async function submitForm() {
|
||||
expect_end_time: form.expect_end_time || null,
|
||||
total_amount: form.total_amount,
|
||||
remark: form.remark || null,
|
||||
sender_info: cleanObject(form.sender_info),
|
||||
receiver_info: cleanObject(form.receiver_info),
|
||||
extend_props: propsToObject(form.extend_props),
|
||||
} as Record<string, unknown>
|
||||
await inboundOrderApi.update(editId.value as number, payload as any)
|
||||
ElMessage.success('保存成功')
|
||||
@ -446,7 +416,13 @@ async function saveItems() {
|
||||
}
|
||||
|
||||
onMounted(async () => {
|
||||
// 支持仪表盘等入口带筛选条件跳转(?status=1)
|
||||
const status = Number(route.query.status)
|
||||
if (route.query.status != null && route.query.status !== '' && !Number.isNaN(status)) {
|
||||
query.status = status
|
||||
}
|
||||
await fetchWarehouses()
|
||||
await fetchExpressCompanies()
|
||||
await fetchList()
|
||||
})
|
||||
</script>
|
||||
@ -520,7 +496,9 @@ onMounted(async () => {
|
||||
<el-table-column label="商品种类" width="100" align="right">
|
||||
<template #default="{ row }">{{ row.item_kind ?? 0 }}</template>
|
||||
</el-table-column>
|
||||
<el-table-column prop="created_at" label="创建时间" width="180" />
|
||||
<el-table-column prop="created_at" label="创建时间" width="180">
|
||||
<template #default="{ row }">{{ formatDateTime(row.created_at) }}</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="操作" width="300" fixed="right">
|
||||
<template #default="{ row }">
|
||||
<el-button v-if="row.status === 1" link type="primary" size="small" :disabled="transiting || !hasItems(row)" @click="transitRow('audit', row)">审核</el-button>
|
||||
@ -591,27 +569,18 @@ onMounted(async () => {
|
||||
<el-descriptions-item label="仓库">{{ currentOrder.warehouse?.name || '-' }}</el-descriptions-item>
|
||||
<el-descriptions-item label="供应商">{{ currentOrder.supplier || '-' }}</el-descriptions-item>
|
||||
<el-descriptions-item label="操作人">{{ currentOrder.operator || '-' }}</el-descriptions-item>
|
||||
<el-descriptions-item label="审核人">{{ currentOrder.auditor?.nickname || currentOrder.auditor?.username || '-' }}</el-descriptions-item>
|
||||
<el-descriptions-item label="审核时间">{{ currentOrder.audit_time || '-' }}</el-descriptions-item>
|
||||
<el-descriptions-item label="审核时间">{{ formatDateTime(currentOrder.audit_time) }}</el-descriptions-item>
|
||||
<el-descriptions-item label="总金额">{{ currentOrder.total_amount }}</el-descriptions-item>
|
||||
<el-descriptions-item v-if="currentOrder.status === 5" label="作废人">{{ currentOrder.voider?.nickname || currentOrder.voider?.username || '-' }}</el-descriptions-item>
|
||||
<el-descriptions-item v-if="currentOrder.status === 5" label="作废时间">{{ currentOrder.void_at || '-' }}</el-descriptions-item>
|
||||
<el-descriptions-item v-if="currentOrder.status === 5" label="作废时间">{{ formatDateTime(currentOrder.void_at) }}</el-descriptions-item>
|
||||
<el-descriptions-item v-if="currentOrder.status === 5" label="作废原因">{{ currentOrder.void_reason || '-' }}</el-descriptions-item>
|
||||
<el-descriptions-item label="备注" :span="3">{{ currentOrder.remark || '-' }}</el-descriptions-item>
|
||||
</el-descriptions>
|
||||
|
||||
<h4>收件信息 <span class="hint">receiverInfo</span></h4>
|
||||
<el-descriptions v-if="currentOrder.receiver_info" :column="2" border size="small">
|
||||
<el-descriptions-item v-for="f in SENDER_FIELDS" :key="'r' + f.key" :label="f.label">
|
||||
{{ currentOrder.receiver_info[f.key] || '-' }}
|
||||
</el-descriptions-item>
|
||||
</el-descriptions>
|
||||
<p v-else class="muted">无</p>
|
||||
|
||||
<h4>WMS 推送结果</h4>
|
||||
<template v-if="currentOrder.wms_push_result">
|
||||
<el-descriptions :column="2" border size="small">
|
||||
<el-descriptions-item label="推送时间">{{ currentOrder.pushed_at || '-' }}</el-descriptions-item>
|
||||
<el-descriptions-item label="推送时间">{{ formatDateTime(currentOrder.pushed_at) }}</el-descriptions-item>
|
||||
<el-descriptions-item label="结果">
|
||||
<el-tag :type="currentOrder.wms_push_result.success ? 'success' : 'danger'">
|
||||
{{ currentOrder.wms_push_result.success ? '成功' : '失败' }}
|
||||
@ -739,29 +708,23 @@ onMounted(async () => {
|
||||
<el-input v-model="form.purchase_order_code" placeholder="选填" />
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col :span="12">
|
||||
<el-form-item label="操作人">
|
||||
<el-input v-model="form.operator" placeholder="选填" />
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col :span="12">
|
||||
<el-form-item label="操作员编码">
|
||||
<el-input v-model="form.operator_code" placeholder="选填" />
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col :span="12">
|
||||
<el-form-item label="运单号">
|
||||
<el-input v-model="form.express_code" placeholder="选填" />
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col :span="12">
|
||||
<el-form-item label="物流公司编码">
|
||||
<el-input v-model="form.logistics_code" placeholder="选填,如 SF/YTO" />
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col :span="12">
|
||||
<el-form-item label="物流公司名称">
|
||||
<el-input v-model="form.logistics_name" placeholder="选填" />
|
||||
<el-form-item label="物流公司">
|
||||
<el-select
|
||||
v-model="form.logistics_code"
|
||||
placeholder="选填,推送为 logisticsCode"
|
||||
clearable
|
||||
filterable
|
||||
style="width: 100%"
|
||||
@change="handleExpressChange"
|
||||
>
|
||||
<el-option v-for="c in expressCompanies" :key="c.code" :label="`${c.name}(${c.code})`" :value="c.code" />
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col :span="12">
|
||||
@ -770,12 +733,12 @@ onMounted(async () => {
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col :span="12">
|
||||
<el-form-item label="预期到货(起)">
|
||||
<el-form-item label="预计到货">
|
||||
<el-date-picker v-model="form.expect_start_time" type="datetime" placeholder="选填" style="width: 100%" value-format="YYYY-MM-DD HH:mm:ss" />
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col :span="12">
|
||||
<el-form-item label="预期到货(止)">
|
||||
<el-form-item label="最迟到货">
|
||||
<el-date-picker v-model="form.expect_end_time" type="datetime" placeholder="选填" style="width: 100%" value-format="YYYY-MM-DD HH:mm:ss" />
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
@ -790,53 +753,6 @@ onMounted(async () => {
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
</el-row>
|
||||
|
||||
<!-- WMS 扩展信息 -->
|
||||
<el-collapse class="ext-collapse">
|
||||
<el-collapse-item title="WMS 扩展信息(选填)" name="ext">
|
||||
<div class="ext-block">
|
||||
<div class="ext-subtitle"><span>发件人 (senderInfo)</span></div>
|
||||
<el-row :gutter="12">
|
||||
<el-col :span="8" v-for="f in SENDER_FIELDS" :key="'s' + f.key">
|
||||
<el-form-item :label="f.label" label-width="70px" style="margin-bottom: 8px">
|
||||
<el-input v-model="form.sender_info[f.key]" />
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
</el-row>
|
||||
</div>
|
||||
|
||||
<div class="ext-block">
|
||||
<div class="ext-subtitle"><span>收件人 (receiverInfo)</span></div>
|
||||
<el-row :gutter="12">
|
||||
<el-col :span="8" v-for="f in SENDER_FIELDS" :key="'r' + f.key">
|
||||
<el-form-item :label="f.label" label-width="70px" style="margin-bottom: 8px">
|
||||
<el-input v-model="form.receiver_info[f.key]" />
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
</el-row>
|
||||
</div>
|
||||
|
||||
<div class="ext-block">
|
||||
<div class="ext-subtitle">
|
||||
<span>扩展属性 (extendProps)</span>
|
||||
<el-button size="small" @click="form.extend_props.push({ key: '', value: '' })">添加</el-button>
|
||||
</div>
|
||||
<el-table :data="form.extend_props" size="small" border>
|
||||
<el-table-column label="键" width="200">
|
||||
<template #default="{ row }"><el-input v-model="row.key" placeholder="key" /></template>
|
||||
</el-table-column>
|
||||
<el-table-column label="值">
|
||||
<template #default="{ row }"><el-input v-model="row.value" placeholder="value" /></template>
|
||||
</el-table-column>
|
||||
<el-table-column label="" width="60">
|
||||
<template #default="{ $index }">
|
||||
<el-button link type="danger" @click="form.extend_props.splice($index, 1)">删除</el-button>
|
||||
</template>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
</div>
|
||||
</el-collapse-item>
|
||||
</el-collapse>
|
||||
</el-form>
|
||||
<template #footer>
|
||||
<el-button @click="dialogVisible = false">取消</el-button>
|
||||
@ -980,24 +896,6 @@ onMounted(async () => {
|
||||
.ext-wrap > h4:first-child {
|
||||
margin-top: 0;
|
||||
}
|
||||
.hint {
|
||||
font-weight: 400;
|
||||
color: #c0c4cc;
|
||||
}
|
||||
.ext-collapse {
|
||||
margin-top: 8px;
|
||||
}
|
||||
.ext-block {
|
||||
margin-bottom: 8px;
|
||||
}
|
||||
.ext-subtitle {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
margin-bottom: 8px;
|
||||
font-weight: 600;
|
||||
color: #606266;
|
||||
}
|
||||
.muted {
|
||||
color: #909399;
|
||||
}
|
||||
|
||||
@ -118,7 +118,6 @@ const registerVisible = ref(false)
|
||||
const registerFormRef = ref<FormInstance>()
|
||||
const registerForm = reactive({
|
||||
username: '',
|
||||
nickname: '',
|
||||
email: '',
|
||||
code: '',
|
||||
password: '',
|
||||
@ -154,7 +153,6 @@ const registerSending = ref(false)
|
||||
|
||||
function openRegister() {
|
||||
registerForm.username = ''
|
||||
registerForm.nickname = ''
|
||||
registerForm.email = ''
|
||||
registerForm.code = ''
|
||||
registerForm.password = ''
|
||||
@ -193,7 +191,6 @@ async function handleRegister() {
|
||||
password: registerForm.password,
|
||||
email: registerForm.email,
|
||||
code: registerForm.code,
|
||||
nickname: registerForm.nickname || undefined,
|
||||
phone: registerForm.phone || undefined,
|
||||
})
|
||||
ElMessage.success('注册成功,已自动登录')
|
||||
@ -404,9 +401,6 @@ onUnmounted(() => {
|
||||
:prefix-icon="Lock"
|
||||
/>
|
||||
</el-form-item>
|
||||
<el-form-item label="昵称" prop="nickname">
|
||||
<el-input v-model="registerForm.nickname" placeholder="选填,默认与账号相同" />
|
||||
</el-form-item>
|
||||
<el-form-item label="手机号" prop="phone">
|
||||
<el-input v-model="registerForm.phone" placeholder="选填" />
|
||||
</el-form-item>
|
||||
|
||||
@ -34,7 +34,6 @@ interface HeaderForm {
|
||||
order_type: string
|
||||
is_urgency: 'Y' | 'N'
|
||||
invoice_flag: 'Y' | 'N'
|
||||
operator_name: string
|
||||
logistics_code: string
|
||||
logistics_name: string
|
||||
total_amount: number
|
||||
@ -63,7 +62,6 @@ function emptyForm(): HeaderForm {
|
||||
order_type: DEFAULT_ORDER_TYPE,
|
||||
is_urgency: 'N',
|
||||
invoice_flag: 'N',
|
||||
operator_name: '',
|
||||
logistics_code: '',
|
||||
logistics_name: '',
|
||||
total_amount: 0,
|
||||
@ -256,7 +254,6 @@ async function submit() {
|
||||
order_type: form.order_type,
|
||||
is_urgency: form.is_urgency,
|
||||
invoice_flag: form.invoice_flag,
|
||||
operator_name: form.operator_name || null,
|
||||
logistics_code: form.logistics_code || null,
|
||||
logistics_name: form.logistics_name || null,
|
||||
total_amount: form.total_amount,
|
||||
@ -388,11 +385,6 @@ onMounted(async () => {
|
||||
</el-radio-group>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col :span="6">
|
||||
<el-form-item label="操作人">
|
||||
<el-input v-model="form.operator_name" placeholder="选填" />
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col :span="12">
|
||||
<el-form-item label="物流公司">
|
||||
<el-select
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
<script setup lang="ts">
|
||||
import { computed, onMounted, reactive, ref, watch } from 'vue'
|
||||
import { useRouter } from 'vue-router'
|
||||
import { useRoute, useRouter } from 'vue-router'
|
||||
import { ElMessage, ElMessageBox, type FormInstance, type FormRules } from 'element-plus'
|
||||
import {
|
||||
getOrderDeliveries,
|
||||
@ -41,6 +41,7 @@ import { DEFAULT_PAGE_SIZE, useListPage } from '@/composables/useListPage'
|
||||
import VirtualTable from '@/components/VirtualTable.vue'
|
||||
import VirtualSelect from '@/components/VirtualSelect.vue'
|
||||
import type { VirtualColumn } from '@/components/virtualTable'
|
||||
import { formatDateTime } from '@/utils/datetime'
|
||||
|
||||
/** 状态:1待处理 2已审核 3已推送 4已完成 5已作废 9已取消(与出入库单一致) */
|
||||
const STATUS_LABELS: Record<number, string> = {
|
||||
@ -171,7 +172,6 @@ interface DeliveryForm {
|
||||
order_type: string
|
||||
is_urgency: 'Y' | 'N'
|
||||
invoice_flag: 'Y' | 'N'
|
||||
operator_name: string
|
||||
total_amount: number
|
||||
discount_amount: number
|
||||
freight: number
|
||||
@ -201,7 +201,6 @@ function emptyForm(): DeliveryForm {
|
||||
order_type: DEFAULT_ORDER_TYPE,
|
||||
is_urgency: 'N',
|
||||
invoice_flag: 'N',
|
||||
operator_name: '',
|
||||
total_amount: 0,
|
||||
discount_amount: 0,
|
||||
freight: 0,
|
||||
@ -266,6 +265,7 @@ function handleExpressChange(code: string | null) {
|
||||
form.logistics_name = company ? company.name : ''
|
||||
}
|
||||
|
||||
const route = useRoute()
|
||||
const router = useRouter()
|
||||
|
||||
/** 新增发货单改为独立整页(菜单「创建发货单」,路径 /order-create) */
|
||||
@ -508,7 +508,6 @@ function openEdit(row: OrderDelivery) {
|
||||
order_type: row.order_type || DEFAULT_ORDER_TYPE,
|
||||
is_urgency: row.is_urgency === 'Y' ? 'Y' : 'N',
|
||||
invoice_flag: row.invoice_flag === 'Y' ? 'Y' : 'N',
|
||||
operator_name: row.operator_name || '',
|
||||
total_amount: Number(row.total_amount) || 0,
|
||||
discount_amount: Number(row.discount_amount) || 0,
|
||||
freight: Number(row.freight) || 0,
|
||||
@ -735,7 +734,6 @@ const itemForm = reactive({
|
||||
retail_price: null as number | null,
|
||||
ext_code: '',
|
||||
inventory_type: 'ZP' as 'ZP' | 'CC',
|
||||
owner_code: '',
|
||||
source_order_code: '',
|
||||
sub_source_order_code: '',
|
||||
stock_id: null as number | null,
|
||||
@ -752,7 +750,6 @@ function resetItemForm() {
|
||||
itemForm.retail_price = null
|
||||
itemForm.ext_code = ''
|
||||
itemForm.inventory_type = 'ZP'
|
||||
itemForm.owner_code = ''
|
||||
itemForm.source_order_code = ''
|
||||
itemForm.sub_source_order_code = ''
|
||||
itemForm.stock_id = null
|
||||
@ -788,7 +785,6 @@ function openItemEdit(row: OrderDeliveryLine) {
|
||||
itemForm.retail_price = row.retail_price == null ? null : Number(row.retail_price)
|
||||
itemForm.ext_code = row.ext_code || ''
|
||||
itemForm.inventory_type = row.inventory_type === 'CC' ? 'CC' : 'ZP'
|
||||
itemForm.owner_code = row.owner_code || ''
|
||||
itemForm.source_order_code = row.source_order_code || ''
|
||||
itemForm.sub_source_order_code = row.sub_source_order_code || ''
|
||||
itemForm.stock_id = row.stock_id
|
||||
@ -806,7 +802,6 @@ function buildItemPayload() {
|
||||
retail_price: itemForm.retail_price,
|
||||
ext_code: itemForm.ext_code || null,
|
||||
inventory_type: itemForm.inventory_type,
|
||||
owner_code: itemForm.owner_code || null,
|
||||
source_order_code: itemForm.source_order_code || null,
|
||||
sub_source_order_code: itemForm.sub_source_order_code || null,
|
||||
stock_id: itemForm.stock_id,
|
||||
@ -855,6 +850,11 @@ async function handleDeleteItem(row: OrderDeliveryLine) {
|
||||
}
|
||||
|
||||
onMounted(async () => {
|
||||
// 支持仪表盘等入口带筛选条件跳转(?status=1)
|
||||
const status = Number(route.query.status)
|
||||
if (route.query.status != null && route.query.status !== '' && !Number.isNaN(status)) {
|
||||
query.status = status
|
||||
}
|
||||
await fetchOptions()
|
||||
await fetchList()
|
||||
})
|
||||
@ -996,7 +996,9 @@ onMounted(async () => {
|
||||
<template v-else>{{ row.express_code || '-' }}</template>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column prop="created_at" label="创建时间" width="180" />
|
||||
<el-table-column prop="created_at" label="创建时间" width="180">
|
||||
<template #default="{ row }">{{ formatDateTime(row.created_at) }}</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="操作" width="300" fixed="right">
|
||||
<template #default="{ row }">
|
||||
<el-button v-if="row.status === 1" link type="primary" @click="openEdit(row)">编辑</el-button>
|
||||
@ -1114,9 +1116,6 @@ onMounted(async () => {
|
||||
<el-radio value="Y">是</el-radio>
|
||||
</el-radio-group>
|
||||
</el-form-item>
|
||||
<el-form-item label="操作人">
|
||||
<el-input v-model="form.operator_name" placeholder="operatorName,选填" />
|
||||
</el-form-item>
|
||||
|
||||
<el-divider content-position="left">金额</el-divider>
|
||||
<el-form-item label="订单总金额">
|
||||
@ -1249,9 +1248,6 @@ onMounted(async () => {
|
||||
<el-option label="残次(CC)" value="CC" />
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item label="货主编码">
|
||||
<el-input v-model="itemForm.owner_code" placeholder="ownerCode,选填" />
|
||||
</el-form-item>
|
||||
<el-form-item label="来源订单编码">
|
||||
<el-input v-model="itemForm.source_order_code" placeholder="sourceOrderCode,选填" />
|
||||
</el-form-item>
|
||||
@ -1443,7 +1439,7 @@ onMounted(async () => {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
overflow: hidden;
|
||||
padding: 12px 16px;
|
||||
padding: 10px 12px;
|
||||
}
|
||||
.top-table-wrap {
|
||||
flex: 1;
|
||||
|
||||
@ -36,7 +36,6 @@ interface HeaderForm {
|
||||
customer: string
|
||||
express_code: string
|
||||
express_name: string
|
||||
operator: string
|
||||
total_amount: number
|
||||
remark: string
|
||||
receiver_name: string
|
||||
@ -66,7 +65,6 @@ function emptyForm(): HeaderForm {
|
||||
customer: '',
|
||||
express_code: '',
|
||||
express_name: '',
|
||||
operator: '',
|
||||
total_amount: 0,
|
||||
remark: '',
|
||||
receiver_name: '',
|
||||
@ -168,7 +166,6 @@ async function submit() {
|
||||
customer: form.customer || null,
|
||||
express_code: form.express_code || null,
|
||||
express_name: form.express_name || null,
|
||||
operator: form.operator || null,
|
||||
total_amount: form.total_amount,
|
||||
remark: form.remark || null,
|
||||
receiver_name: form.receiver_name || null,
|
||||
@ -299,11 +296,6 @@ onMounted(async () => {
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col :span="6">
|
||||
<el-form-item label="操作人">
|
||||
<el-input v-model="form.operator" placeholder="选填" />
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col :span="6">
|
||||
<el-form-item label="单据金额">
|
||||
<el-input-number v-model="form.total_amount" :min="0" :precision="2" style="width: 100%" />
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
<script setup lang="ts">
|
||||
import { computed, onMounted, reactive, ref } from 'vue'
|
||||
import { useRouter } from 'vue-router'
|
||||
import { useRoute, useRouter } from 'vue-router'
|
||||
import { ElMessage, ElMessageBox, type FormInstance, type FormRules } from 'element-plus'
|
||||
import {
|
||||
outboundOrderApi,
|
||||
@ -18,6 +18,7 @@ import ListPager from '@/components/ListPager.vue'
|
||||
import VirtualSelect from '@/components/VirtualSelect.vue'
|
||||
import ProductSelect from '@/components/ProductSelect.vue'
|
||||
import { DEFAULT_PAGE_SIZE, useListPage } from '@/composables/useListPage'
|
||||
import { formatDateTime } from '@/utils/datetime'
|
||||
|
||||
const STATUS_LABELS: Record<number, string> = {
|
||||
1: '待出库', 2: '已审核', 3: '已推送', 4: '已完成', 5: '已作废', 9: '已取消',
|
||||
@ -85,6 +86,7 @@ function hasItems(row: { item_kind?: number | string | null }) {
|
||||
}
|
||||
|
||||
/* -------------------- 新增 / 编辑 单据头 -------------------- */
|
||||
const route = useRoute()
|
||||
const router = useRouter()
|
||||
const dialogVisible = ref(false)
|
||||
const submitting = ref(false)
|
||||
@ -102,7 +104,6 @@ function emptyForm() {
|
||||
shop_id: null as number | null,
|
||||
outbound_type: 'PTCK',
|
||||
customer: '',
|
||||
operator: '',
|
||||
total_amount: 0,
|
||||
remark: '',
|
||||
express_code: '',
|
||||
@ -144,7 +145,6 @@ async function openEdit(row: OutboundOrder) {
|
||||
shop_id: full.shop_id ?? null,
|
||||
outbound_type: full.outbound_type || 'PTCK',
|
||||
customer: full.customer || '',
|
||||
operator: full.operator || '',
|
||||
total_amount: Number(full.total_amount) || 0,
|
||||
remark: full.remark || '',
|
||||
express_code: full.express_code || '',
|
||||
@ -177,7 +177,6 @@ async function submitForm() {
|
||||
shop_id: form.shop_id || null,
|
||||
outbound_type: form.outbound_type,
|
||||
customer: form.customer || null,
|
||||
operator: form.operator || null,
|
||||
total_amount: form.total_amount,
|
||||
remark: form.remark || null,
|
||||
express_code: form.express_code || null,
|
||||
@ -466,6 +465,11 @@ async function saveItems() {
|
||||
}
|
||||
|
||||
onMounted(async () => {
|
||||
// 支持仪表盘等入口带筛选条件跳转(?status=1)
|
||||
const status = Number(route.query.status)
|
||||
if (route.query.status != null && route.query.status !== '' && !Number.isNaN(status)) {
|
||||
query.status = status
|
||||
}
|
||||
await fetchOptions()
|
||||
await fetchList()
|
||||
})
|
||||
@ -557,7 +561,9 @@ onMounted(async () => {
|
||||
<template v-else>-</template>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column prop="created_at" label="创建时间" width="180" />
|
||||
<el-table-column prop="created_at" label="创建时间" width="180">
|
||||
<template #default="{ row }">{{ formatDateTime(row.created_at) }}</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="操作" width="300" fixed="right">
|
||||
<template #default="{ row }">
|
||||
<el-button v-if="row.status === 1" link type="primary" size="small" :disabled="transiting || !hasItems(row)" @click="transitRow('audit', row)">审核</el-button>
|
||||
@ -610,7 +616,7 @@ onMounted(async () => {
|
||||
</el-descriptions-item>
|
||||
<el-descriptions-item label="备注" :span="2">{{ currentOrder.remark || '-' }}</el-descriptions-item>
|
||||
<el-descriptions-item v-if="currentOrder.status === 5" label="作废人">{{ currentOrder.voider?.nickname || currentOrder.voider?.username || '-' }}</el-descriptions-item>
|
||||
<el-descriptions-item v-if="currentOrder.status === 5" label="作废时间">{{ currentOrder.void_at || '-' }}</el-descriptions-item>
|
||||
<el-descriptions-item v-if="currentOrder.status === 5" label="作废时间">{{ formatDateTime(currentOrder.void_at) }}</el-descriptions-item>
|
||||
<el-descriptions-item v-if="currentOrder.status === 5" label="作废原因">{{ currentOrder.void_reason || '-' }}</el-descriptions-item>
|
||||
</el-descriptions>
|
||||
<div class="status-actions">
|
||||
@ -642,7 +648,7 @@ onMounted(async () => {
|
||||
<h4>WMS 推送结果</h4>
|
||||
<template v-if="currentOrder.wms_push_result">
|
||||
<el-descriptions :column="2" border size="small">
|
||||
<el-descriptions-item label="推送时间">{{ currentOrder.pushed_at || '-' }}</el-descriptions-item>
|
||||
<el-descriptions-item label="推送时间">{{ formatDateTime(currentOrder.pushed_at) }}</el-descriptions-item>
|
||||
<el-descriptions-item label="结果">
|
||||
<el-tag :type="currentOrder.wms_push_result.success ? 'success' : 'danger'">
|
||||
{{ currentOrder.wms_push_result.success ? '成功' : '失败' }}
|
||||
@ -785,11 +791,6 @@ onMounted(async () => {
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col :span="12">
|
||||
<el-form-item label="操作人">
|
||||
<el-input v-model="form.operator" placeholder="选填" />
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col :span="12">
|
||||
<el-form-item label="单据金额">
|
||||
<el-input-number v-model="form.total_amount" :min="0" :precision="2" style="width: 100%" />
|
||||
|
||||
@ -93,7 +93,7 @@ async function handleSubmit() {
|
||||
.create-principal {
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
padding: 32px 16px;
|
||||
padding: 16px 10px;
|
||||
}
|
||||
|
||||
.panel {
|
||||
|
||||
@ -6,6 +6,7 @@ import { useAuthStore } from '@/store/auth'
|
||||
import DataTable from '@/components/DataTable.vue'
|
||||
import ListPager from '@/components/ListPager.vue'
|
||||
import { DEFAULT_PAGE_SIZE, useListPage } from '@/composables/useListPage'
|
||||
import { formatDateTime } from '@/utils/datetime'
|
||||
|
||||
const auth = useAuthStore()
|
||||
|
||||
@ -104,7 +105,9 @@ onMounted(fetchList)
|
||||
</el-tag>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column prop="created_at" label="创建时间" width="180" />
|
||||
<el-table-column prop="created_at" label="创建时间" width="180">
|
||||
<template #default="{ row }">{{ formatDateTime(row.created_at) }}</template>
|
||||
</el-table-column>
|
||||
</DataTable>
|
||||
|
||||
<ListPager
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
<script setup lang="ts">
|
||||
import { onMounted, reactive, ref } from 'vue'
|
||||
import { onMounted, reactive, ref, computed } from 'vue'
|
||||
import { ElMessage, ElMessageBox, type FormInstance, type FormRules } from 'element-plus'
|
||||
import {
|
||||
getPrincipalUsers,
|
||||
@ -9,8 +9,10 @@ import {
|
||||
type PrincipalUserItem,
|
||||
} from '@/api/principalUser'
|
||||
import DataTable from '@/components/DataTable.vue'
|
||||
import ImageUploader from '@/components/ImageUploader.vue'
|
||||
import ListPager from '@/components/ListPager.vue'
|
||||
import { DEFAULT_PAGE_SIZE, useListPage } from '@/composables/useListPage'
|
||||
import { formatDateTime } from '@/utils/datetime'
|
||||
|
||||
const query = reactive({
|
||||
page: 1,
|
||||
@ -27,8 +29,14 @@ function roleText(role: string | null | undefined) {
|
||||
|
||||
function userLabel(row: PrincipalUserItem) {
|
||||
const u = row.user
|
||||
if (!u) return `用户#${row.user_id}`
|
||||
return u.nickname || u.username || u.email || `用户#${row.user_id}`
|
||||
const label = row.name || u?.nickname || u?.username || u?.email
|
||||
return label || `用户#${row.user_id}`
|
||||
}
|
||||
|
||||
/** 头像展示文本:无头像时取名称首字符(支持中文),无名称取登录账号首字符 */
|
||||
function avatarText(row: PrincipalUserItem) {
|
||||
const source = (row.name || row.user?.nickname || row.user?.username || '').trim()
|
||||
return source ? Array.from(source)[0] : ''
|
||||
}
|
||||
|
||||
const { loading, list, total, elapsed, fetchList, search, handlePageChange, handleSizeChange } = useListPage({
|
||||
@ -51,13 +59,18 @@ function reset() {
|
||||
const inviteVisible = ref(false)
|
||||
const inviteSubmitting = ref(false)
|
||||
const inviteFormRef = ref<FormInstance>()
|
||||
const inviteForm = reactive({ email: '', name: '' })
|
||||
const inviteForm = reactive({ email: '', name: '', avatar: null as string | null })
|
||||
/** 头像上传组件的 model 为 string[](单张) */
|
||||
const inviteAvatarList = computed({
|
||||
get: () => (inviteForm.avatar ? [ inviteForm.avatar ] : []),
|
||||
set: (value: string[]) => { inviteForm.avatar = value[0] || null },
|
||||
})
|
||||
const inviteRules: FormRules = {
|
||||
email: [
|
||||
{ required: true, message: '请输入邮箱', trigger: 'blur' },
|
||||
{ type: 'email', message: '邮箱格式不正确', trigger: 'blur' },
|
||||
],
|
||||
name: [{ required: true, message: '请输入用户名称', trigger: 'blur' }],
|
||||
name: [{ required: true, message: '请输入名称', trigger: 'blur' }],
|
||||
}
|
||||
|
||||
/** 邀请成功后返回的账号信息(初始密码仅返回一次) */
|
||||
@ -95,6 +108,7 @@ async function copyText(text: string) {
|
||||
function openInvite() {
|
||||
inviteForm.email = ''
|
||||
inviteForm.name = ''
|
||||
inviteForm.avatar = null
|
||||
inviteVisible.value = true
|
||||
}
|
||||
|
||||
@ -124,13 +138,20 @@ const editVisible = ref(false)
|
||||
const editSubmitting = ref(false)
|
||||
const editFormRef = ref<FormInstance>()
|
||||
const editId = ref<number | null>(null)
|
||||
const editForm = reactive({ role: 'member', status: 1 })
|
||||
const editForm = reactive({ name: '', avatar: null as string | null, role: 'member', status: 1 })
|
||||
const editAvatarList = computed({
|
||||
get: () => (editForm.avatar ? [ editForm.avatar ] : []),
|
||||
set: (value: string[]) => { editForm.avatar = value[0] || null },
|
||||
})
|
||||
const editRules: FormRules = {
|
||||
name: [{ required: true, message: '请输入名称', trigger: 'blur' }],
|
||||
role: [{ required: true, message: '请选择角色', trigger: 'change' }],
|
||||
}
|
||||
|
||||
function openEdit(row: PrincipalUserItem) {
|
||||
editId.value = row.id
|
||||
editForm.name = row.name || row.user?.nickname || row.user?.username || ''
|
||||
editForm.avatar = row.avatar || null
|
||||
editForm.role = row.role || 'member'
|
||||
editForm.status = row.status
|
||||
editVisible.value = true
|
||||
@ -142,7 +163,12 @@ async function submitEdit() {
|
||||
if (!valid) return
|
||||
editSubmitting.value = true
|
||||
try {
|
||||
await updatePrincipalUser(editId.value as number, { role: editForm.role, status: editForm.status })
|
||||
await updatePrincipalUser(editId.value as number, {
|
||||
name: editForm.name,
|
||||
avatar: editForm.avatar,
|
||||
role: editForm.role,
|
||||
status: editForm.status,
|
||||
})
|
||||
ElMessage.success('保存成功')
|
||||
editVisible.value = false
|
||||
await fetchList()
|
||||
@ -206,8 +232,13 @@ onMounted(fetchList)
|
||||
</el-form>
|
||||
|
||||
<DataTable :loading="loading" :data="list">
|
||||
<el-table-column label="用户" min-width="140">
|
||||
<template #default="{ row }">{{ userLabel(row) }}</template>
|
||||
<el-table-column label="用户" min-width="180">
|
||||
<template #default="{ row }">
|
||||
<div class="user-cell">
|
||||
<el-avatar :size="28" :src="row.avatar || undefined">{{ avatarText(row) }}</el-avatar>
|
||||
<span>{{ userLabel(row) }}</span>
|
||||
</div>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="邮箱" prop="user.email" min-width="180" />
|
||||
<el-table-column label="角色" width="100">
|
||||
@ -223,7 +254,9 @@ onMounted(fetchList)
|
||||
</el-tag>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column prop="created_at" label="创建时间" width="180" />
|
||||
<el-table-column prop="created_at" label="创建时间" width="180">
|
||||
<template #default="{ row }">{{ formatDateTime(row.created_at) }}</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="操作" width="160" fixed="right">
|
||||
<template #default="{ row }">
|
||||
<el-button link type="primary" @click="openEdit(row)">编辑</el-button>
|
||||
@ -246,8 +279,11 @@ onMounted(fetchList)
|
||||
<el-form-item label="邮箱" prop="email">
|
||||
<el-input v-model="inviteForm.email" placeholder="被邀请人邮箱,将作为登录账号" />
|
||||
</el-form-item>
|
||||
<el-form-item label="用户名称" prop="name">
|
||||
<el-input v-model="inviteForm.name" placeholder="昵称 / 姓名" />
|
||||
<el-form-item label="名称" prop="name">
|
||||
<el-input v-model="inviteForm.name" placeholder="该账号在此主体下的名称" />
|
||||
</el-form-item>
|
||||
<el-form-item label="头像">
|
||||
<ImageUploader v-model="inviteAvatarList" :limit="1" />
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
<template #footer>
|
||||
@ -258,6 +294,12 @@ onMounted(fetchList)
|
||||
|
||||
<el-dialog v-model="editVisible" title="编辑成员" width="480px">
|
||||
<el-form ref="editFormRef" :model="editForm" :rules="editRules" label-width="88px">
|
||||
<el-form-item label="名称" prop="name">
|
||||
<el-input v-model="editForm.name" placeholder="该账号在此主体下的名称" />
|
||||
</el-form-item>
|
||||
<el-form-item label="头像">
|
||||
<ImageUploader v-model="editAvatarList" :limit="1" />
|
||||
</el-form-item>
|
||||
<el-form-item label="角色" prop="role">
|
||||
<el-select v-model="editForm.role" style="width: 100%">
|
||||
<el-option label="所有者" value="owner" />
|
||||
@ -321,6 +363,12 @@ onMounted(fetchList)
|
||||
.search-bar {
|
||||
margin-bottom: 16px;
|
||||
}
|
||||
/* 列表用户列:头像 + 名称 */
|
||||
.user-cell {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 8px;
|
||||
}
|
||||
.copy-row {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
|
||||
@ -14,6 +14,7 @@ import SplitLayout from '@/components/SplitLayout.vue'
|
||||
import DataTable from '@/components/DataTable.vue'
|
||||
import ListPager from '@/components/ListPager.vue'
|
||||
import { DEFAULT_PAGE_SIZE, useListPage } from '@/composables/useListPage'
|
||||
import { formatDateTime } from '@/utils/datetime'
|
||||
|
||||
const PLATFORMS = [
|
||||
{ label: '淘宝/天猫', value: 'taobao' },
|
||||
@ -277,10 +278,10 @@ onMounted(fetchList)
|
||||
{{ currentShop.contact_phone || '-' }}
|
||||
</el-descriptions-item>
|
||||
<el-descriptions-item label="创建时间">
|
||||
{{ currentShop.created_at || '-' }}
|
||||
{{ formatDateTime(currentShop.created_at) }}
|
||||
</el-descriptions-item>
|
||||
<el-descriptions-item label="更新时间">
|
||||
{{ currentShop.updated_at || '-' }}
|
||||
{{ formatDateTime(currentShop.updated_at) }}
|
||||
</el-descriptions-item>
|
||||
<el-descriptions-item label="备注" :span="3">
|
||||
{{ currentShop.remark || '-' }}
|
||||
@ -301,7 +302,7 @@ onMounted(fetchList)
|
||||
{{ currentShop.stats?.order_amount ?? 0 }}
|
||||
</el-descriptions-item>
|
||||
<el-descriptions-item label="最近订单时间" :span="2">
|
||||
{{ currentShop.stats?.latest_order_at || '暂无订单' }}
|
||||
{{ currentShop.stats?.latest_order_at ? formatDateTime(currentShop.stats.latest_order_at) : '暂无订单' }}
|
||||
</el-descriptions-item>
|
||||
</el-descriptions>
|
||||
</template>
|
||||
@ -374,7 +375,7 @@ onMounted(fetchList)
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
overflow: hidden;
|
||||
padding: 12px 16px;
|
||||
padding: 10px 12px;
|
||||
}
|
||||
.page-header {
|
||||
display: flex;
|
||||
|
||||
@ -16,6 +16,7 @@ import DataTable from '@/components/DataTable.vue'
|
||||
import ListPager from '@/components/ListPager.vue'
|
||||
import { DEFAULT_PAGE_SIZE, useListPage } from '@/composables/useListPage'
|
||||
import VirtualTable from '@/components/VirtualTable.vue'
|
||||
import { formatDateTime } from '@/utils/datetime'
|
||||
import VirtualSelect from '@/components/VirtualSelect.vue'
|
||||
import type { VirtualColumn } from '@/components/virtualTable'
|
||||
|
||||
@ -467,7 +468,9 @@ onMounted(async () => {
|
||||
<el-table-column label="商品种类" width="100" align="right">
|
||||
<template #default="{ row }">{{ row.item_kind ?? 0 }}</template>
|
||||
</el-table-column>
|
||||
<el-table-column prop="created_at" label="创建时间" width="180" />
|
||||
<el-table-column prop="created_at" label="创建时间" width="180">
|
||||
<template #default="{ row }">{{ formatDateTime(row.created_at) }}</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="操作" width="200" fixed="right">
|
||||
<template #default="{ row }">
|
||||
<el-button link type="primary" @click="openEdit(row)">编辑</el-button>
|
||||
@ -640,7 +643,7 @@ onMounted(async () => {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
overflow: hidden;
|
||||
padding: 12px 16px;
|
||||
padding: 10px 12px;
|
||||
}
|
||||
.page-header {
|
||||
display: flex;
|
||||
|
||||
@ -4,6 +4,7 @@ import DataTable from '@/components/DataTable.vue'
|
||||
import ListPager from '@/components/ListPager.vue'
|
||||
import ProductSelect from '@/components/ProductSelect.vue'
|
||||
import { DEFAULT_PAGE_SIZE, useListPage } from '@/composables/useListPage'
|
||||
import { formatDateTime } from '@/utils/datetime'
|
||||
import {
|
||||
getStockRecords,
|
||||
getStockRecordBizTypes,
|
||||
@ -202,7 +203,9 @@ onMounted(() => {
|
||||
|
||||
<div class="table-wrap">
|
||||
<DataTable :loading="loading" :data="list" class="fill-table">
|
||||
<el-table-column prop="created_at" label="记录时间" width="165" />
|
||||
<el-table-column prop="created_at" label="记录时间" width="165">
|
||||
<template #default="{ row }">{{ formatDateTime(row.created_at) }}</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="业务动作" width="130">
|
||||
<template #default="{ row }">
|
||||
<el-tag size="small" :type="BIZ_TAG_TYPES[row.biz_type] || 'info'">
|
||||
|
||||
@ -3,12 +3,13 @@ import { onMounted, reactive, ref } from 'vue'
|
||||
import { ElMessage, type FormInstance, type FormRules } from 'element-plus'
|
||||
import { useAuthStore } from '@/store/auth'
|
||||
import { updateProfile, changePassword } from '@/api/user'
|
||||
import { formatDateTime } from '@/utils/datetime'
|
||||
|
||||
const auth = useAuthStore()
|
||||
|
||||
const formRef = ref<FormInstance>()
|
||||
const submitting = ref(false)
|
||||
const form = reactive({ nickname: '', email: '', phone: '', avatar: '' })
|
||||
const form = reactive({ email: '', phone: '' })
|
||||
const rules: FormRules = {
|
||||
email: [{ type: 'email', message: '邮箱格式不正确', trigger: 'blur' }],
|
||||
phone: [{ pattern: /^1[3-9]\d{9}$|^[\d-+()\s]{6,20}$/, message: '手机号格式不正确', trigger: 'blur' }],
|
||||
@ -18,10 +19,8 @@ const rules: FormRules = {
|
||||
function fillForm() {
|
||||
const u = auth.user
|
||||
if (!u) return
|
||||
form.nickname = u.nickname || ''
|
||||
form.email = u.email || ''
|
||||
form.phone = u.phone || ''
|
||||
form.avatar = u.avatar || ''
|
||||
}
|
||||
|
||||
onMounted(async () => {
|
||||
@ -112,24 +111,18 @@ async function submitPwd() {
|
||||
{{ auth.user?.status === 1 ? '启用' : '禁用' }}
|
||||
</el-tag>
|
||||
</el-descriptions-item>
|
||||
<el-descriptions-item label="最后登录">{{ auth.user?.last_login_at || '暂无' }}</el-descriptions-item>
|
||||
<el-descriptions-item label="最后登录">{{ auth.user?.last_login_at ? formatDateTime(auth.user.last_login_at) : '暂无' }}</el-descriptions-item>
|
||||
</el-descriptions>
|
||||
|
||||
<el-divider content-position="left">修改资料</el-divider>
|
||||
|
||||
<el-form ref="formRef" :model="form" :rules="rules" label-width="96px" class="profile-form">
|
||||
<el-form-item label="昵称" prop="nickname">
|
||||
<el-input v-model="form.nickname" placeholder="选填" />
|
||||
</el-form-item>
|
||||
<el-form-item label="邮箱" prop="email">
|
||||
<el-input v-model="form.email" placeholder="选填" />
|
||||
</el-form-item>
|
||||
<el-form-item label="手机号" prop="phone">
|
||||
<el-input v-model="form.phone" placeholder="选填" />
|
||||
</el-form-item>
|
||||
<el-form-item label="头像URL" prop="avatar">
|
||||
<el-input v-model="form.avatar" placeholder="选填" />
|
||||
</el-form-item>
|
||||
<el-form-item>
|
||||
<el-button type="primary" :loading="submitting" @click="submitProfile">保存资料</el-button>
|
||||
<el-button @click="openPwd">修改密码</el-button>
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user