diff --git a/frontend/src/App.vue b/frontend/src/App.vue index 9272709..d09dd9a 100644 --- a/frontend/src/App.vue +++ b/frontend/src/App.vue @@ -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; +} diff --git a/frontend/src/api/auth.ts b/frontend/src/api/auth.ts index e2a92f1..3390d7e 100644 --- a/frontend/src/api/auth.ts +++ b/frontend/src/api/auth.ts @@ -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 } diff --git a/frontend/src/api/dashboard.ts b/frontend/src/api/dashboard.ts new file mode 100644 index 0000000..3171aaa --- /dev/null +++ b/frontend/src/api/dashboard.ts @@ -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 | 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} 报表数据 + */ +export function getDashboardReport(params?: DashboardParams) { + return get('/dashboard/report', params) +} diff --git a/frontend/src/api/inboundOrder.ts b/frontend/src/api/inboundOrder.ts index 9eea061..b8565b8 100644 --- a/frontend/src/api/inboundOrder.ts +++ b/frontend/src/api/inboundOrder.ts @@ -27,8 +27,11 @@ export interface InboundOrder { logistics_code?: string | null logistics_name?: string | null express_code?: string | null + /** 发件人信息(仅本地留存:WMS 入库单报文不识别,不下发) */ sender_info?: Record | null + /** 收件人信息(仅本地留存:WMS 入库单报文不识别,不下发) */ receiver_info?: Record | null + /** 扩展属性(仅本地留存:不下发) */ extend_props?: Record | 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[] diff --git a/frontend/src/api/orderDelivery.ts b/frontend/src/api/orderDelivery.ts index 420b6d9..787e786 100644 --- a/frontend/src/api/orderDelivery.ts +++ b/frontend/src/api/orderDelivery.ts @@ -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 diff --git a/frontend/src/api/outboundOrder.ts b/frontend/src/api/outboundOrder.ts index e878d33..21301dd 100644 --- a/frontend/src/api/outboundOrder.ts +++ b/frontend/src/api/outboundOrder.ts @@ -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) => 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`), diff --git a/frontend/src/api/principalUser.ts b/frontend/src/api/principalUser.ts index 484493b..bb66e67 100644 --- a/frontend/src/api/principalUser.ts +++ b/frontend/src/api/principalUser.ts @@ -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('/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) } diff --git a/frontend/src/components/ProductSelect.vue b/frontend/src/components/ProductSelect.vue index 65cd5c2..f2f7f78 100644 --- a/frontend/src/components/ProductSelect.vue +++ b/frontend/src/components/ProductSelect.vue @@ -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; } diff --git a/frontend/src/components/VirtualTable.vue b/frontend/src/components/VirtualTable.vue index 2423a0b..b60f3ce 100644 --- a/frontend/src/components/VirtualTable.vue +++ b/frontend/src/components/VirtualTable.vue @@ -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; diff --git a/frontend/src/layouts/BasicLayout.vue b/frontend/src/layouts/BasicLayout.vue index 8a2733f..711198d 100644 --- a/frontend/src/layouts/BasicLayout.vue +++ b/frontend/src/layouts/BasicLayout.vue @@ -1,5 +1,5 @@ diff --git a/frontend/src/views/InboundOrder/Create.vue b/frontend/src/views/InboundOrder/Create.vue index 942f85b..b3255a5 100644 --- a/frontend/src/views/InboundOrder/Create.vue +++ b/frontend/src/views/InboundOrder/Create.vue @@ -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([]) +/** 快递公司字典(物流公司下拉选项,不区分主体) */ +const expressCompanies = ref([]) /* -------------------- 单据信息(页面头部) -------------------- */ 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 { - 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>([]) /* -------------------- 商品明细(内联,随单创建) -------------------- */ interface LineItem { @@ -133,26 +119,6 @@ const itemsTotal = computed(() => /* -------------------- 提交 -------------------- */ const submitting = ref(false) -/** 过滤空值:全部为空时返回 null(不下发空对象) */ -function cleanObject(obj: Record) { - const r: Record = {} - 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 = {} - 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 () => { - - - - - - - - - - @@ -305,13 +261,17 @@ onMounted(async () => { - - - - - - - + + + + @@ -326,7 +286,7 @@ onMounted(async () => { - + { - + { - - - - -
-
发件人(senderInfo)
- - - - - - - -
- -
-
收件人(receiverInfo)
- - - - - - - -
- -
-
- 扩展属性(extendProps) - 添加 -
- - - - - - - - - - - -
-
-
@@ -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; -} diff --git a/frontend/src/views/InboundOrder/Index.vue b/frontend/src/views/InboundOrder/Index.vue index 68a481c..9477356 100644 --- a/frontend/src/views/InboundOrder/Index.vue +++ b/frontend/src/views/InboundOrder/Index.vue @@ -1,6 +1,6 @@ @@ -520,7 +496,9 @@ onMounted(async () => { - + + +