diff --git a/frontend/src/api/inboundOrder.ts b/frontend/src/api/inboundOrder.ts index 0bcce4c..9eea061 100644 --- a/frontend/src/api/inboundOrder.ts +++ b/frontend/src/api/inboundOrder.ts @@ -90,7 +90,7 @@ export interface InboundOrderPayload { receiver_info?: unknown extend_props?: unknown total_amount?: number - remark?: string + remark?: string | null items?: InboundItemInput[] } diff --git a/frontend/src/api/orderDelivery.ts b/frontend/src/api/orderDelivery.ts index 4913721..420b6d9 100644 --- a/frontend/src/api/orderDelivery.ts +++ b/frontend/src/api/orderDelivery.ts @@ -74,6 +74,12 @@ export interface OrderDelivery { logistics_code: string | null logistics_name: string | null express_code: string | null + /** 运单号集合(WMS 发货确认回传,多包裹时为多个;express_code 为首个) */ + express_codes?: string[] | null + /** 回传平台店铺状态:0未同步 1同步中 2同步成功 3同步失败(系统托管) */ + shop_sync_status?: number + /** 回传平台店铺的重试次数(系统托管) */ + shop_sync_retry_count?: number logistics_area_code: string | null operator_name: string | null oaid_order_source_code: string | null @@ -302,6 +308,8 @@ export interface BatchScopeParams { from_shop_id?: number /** 原发货仓库ID */ from_warehouse_id?: number + /** 回传平台店铺状态:0未同步 1同步中 2同步成功 3同步失败 */ + shop_sync_status?: number } /** 批量操作结果(审核与推送共用;dry_run 时额外返回 samples) */ @@ -331,9 +339,9 @@ export function pushBatchOrderDeliveries(data: BatchScopeParams) { return post('/order-deliveries/push-batch', data) } -/** 状态流转:驳回 已审核(2)→待处理(1),不换号 */ +/** 状态流转:驳回 已审核(2)→待处理(1),**会变更单号**(基础单号后追加/递增 _N,首次 _1) */ export function rejectOrderDelivery(id: number) { - return post<{ id: number }>(`/order-deliveries/${id}/reject`) + return post<{ id: number; delivery_order_code: string }>(`/order-deliveries/${id}/reject`) } /** 状态流转:取消 →已取消(9) */ @@ -341,9 +349,11 @@ export function cancelOrderDelivery(id: number) { return post<{ id: number }>(`/order-deliveries/${id}/cancel`) } -/** 状态流转:恢复 已取消(9)→待处理(1) */ +/** 状态流转:恢复 已取消(9)→待处理(1);**曾推送过的单据会变更单号**(追加/递增 _N,首次 _1) */ export function restoreOrderDelivery(id: number) { - return post<{ id: number }>(`/order-deliveries/${id}/restore`) + return post<{ id: number; delivery_order_code?: string; bill_no_changed?: boolean }>( + `/order-deliveries/${id}/restore`, + ) } /** 状态流转:作废 已审核(2)→已作废(5) */ diff --git a/frontend/src/api/outboundOrder.ts b/frontend/src/api/outboundOrder.ts index c718b17..e878d33 100644 --- a/frontend/src/api/outboundOrder.ts +++ b/frontend/src/api/outboundOrder.ts @@ -20,6 +20,26 @@ export interface OutboundOrder { total_amount: number | string remark?: string | null stock_deducted?: number + /** 运单号集合(WMS 出库确认回传,多包裹时为多个;列名对齐 wms_order_stockout) */ + waybill_codes?: string[] | null + /** 快递公司编码(推送 deliveryOrder.logisticsCode,如 SF/STO) */ + express_code?: string | null + /** 快递公司名称(按快递公司字典解析的快照) */ + express_name?: string | null + /** 收件人(receiverInfo,推送 WMS stockout.create) */ + receiver_name?: string | null + receiver_company?: string | null + receiver_tel?: string | null + receiver_mobile?: string | null + receiver_email?: string | null + receiver_country_code?: string | null + receiver_province?: string | null + receiver_city?: string | null + receiver_area?: string | null + receiver_town?: string | null + receiver_detail_address?: string | null + receiver_zip_code?: string | null + receiver_id?: string | null void_at?: string | null void_by?: number | null void_reason?: string | null @@ -61,7 +81,24 @@ export interface OutboundOrderPayload { customer?: string | null operator?: string | null total_amount?: number - remark?: string + remark?: string | null + /** 快递公司编码(推送为 deliveryOrder.logisticsCode) */ + express_code?: string | null + /** 快递公司名称(传编码时前端自动带出) */ + express_name?: string | null + receiver_name?: string | null + receiver_company?: string | null + receiver_tel?: string | null + receiver_mobile?: string | null + receiver_email?: string | null + receiver_country_code?: string | null + receiver_province?: string | null + receiver_city?: string | null + receiver_area?: string | null + receiver_town?: string | null + receiver_detail_address?: string | null + receiver_zip_code?: string | null + receiver_id?: string | null items?: OutboundItemInput[] } diff --git a/frontend/src/api/stockRecord.ts b/frontend/src/api/stockRecord.ts new file mode 100644 index 0000000..381a36a --- /dev/null +++ b/frontend/src/api/stockRecord.ts @@ -0,0 +1,60 @@ +import { get } from '@/utils/request' + +/** + * 出入库记录(库存流水):每一次库存变动的完整前后余量 + * 业务动作 biz_type:outbound_lock 出库推送锁定 / outbound_unlock 出库解锁 / + * outbound_deduct 出库确认扣减 / outbound_restore 出库驳回回补 / inbound_increase 入库确认增加 + */ +export interface StockRecordItem { + id: number + principal_id: number + warehouse_id: number | null + product_id: number | null + item_code: string | null + item_name: string | null + item_type: string + biz_type: string + biz_type_label: string + direction: number + direction_label: string + bill_type: number + bill_id: number | null + bill_no: string | null + /** 以下数量列 MySQL DECIMAL 可能以字符串返回,展示时用 Number() 转换 */ + quantity: number | string + quantity_before: number | string + quantity_after: number | string + lock_quantity: number | string + lock_before: number | string + lock_after: number | string + available_before: number | string + available_after: number | string + remark: string | null + created_by: number | null + created_at: string +} + +/** 业务动作选项(后端 stockRecord 常量,用于筛选下拉) */ +export interface StockRecordBizType { + value: string + label: string + direction: number + bill_type: number +} + +/** + * 出入库记录列表 + * @param params page / pageSize / product_id / warehouse_id / biz_type / direction / + * bill_type / item_type / bill_no / keyword / start_time / end_time + */ +export function getStockRecords(params?: object) { + return get<{ list: StockRecordItem[]; total: number; page: number; pageSize: number }>( + '/stock-records', + params, + ) +} + +/** 业务动作选项(筛选下拉,避免前后端枚举文案漂移) */ +export function getStockRecordBizTypes() { + return get('/stock-records/biz-types') +} diff --git a/frontend/src/api/warehouseExpressMapping.ts b/frontend/src/api/warehouseExpressMapping.ts new file mode 100644 index 0000000..2690a9d --- /dev/null +++ b/frontend/src/api/warehouseExpressMapping.ts @@ -0,0 +1,56 @@ +import { get, post, put, del } from '@/utils/request' + +/** + * 仓库快递映射(外部传入的自定义快递编码 → OMS 默认快递编码,按仓库维度) + * + * 外部(WMS)回传的快递编码可能是仓库维度的「自定义编码」(对齐 WMS `wms_express_setting` 的 + * `code`,如 SF.KY / KYSF)。OMS 解析顺序:映射命中 → 用 express_code;未命中 → 外部编码本身 + * 若在快递公司字典里则兜底;两者都没有 → 回传报错提示来此配置。 + */ +export interface WarehouseExpressMappingItem { + id: number + principal_id: number + warehouse_id: number + /** 默认快递编码(OMS/标准编码,如 SF/ZT,关联快递公司字典) */ + express_code: string + /** 快递名称(由 express_code 关联快递公司字典派生,仅返回时附带) */ + express_name?: string + /** 自定义编码(外部传入的快递编码,如 SF.KY/KYSF) */ + custom_code: string + /** 状态:1启用 0禁用(仅启用参与回传解析) */ + status: number + remark: string | null + created_at?: string + updated_at?: string + /** 列表接口 include 带回的仓库 */ + warehouse?: { id: number; code: string; name: string } | null +} + +export interface WarehouseExpressMappingPayload { + warehouse_id: number + /** 默认快递编码(需存在于快递公司字典) */ + express_code: string + /** 自定义编码(同仓库内唯一,服务端统一转大写) */ + custom_code: string + status?: number + remark?: string | null +} + +export function getWarehouseExpressMappings(params?: object) { + return get<{ list: WarehouseExpressMappingItem[]; total: number; page: number; pageSize: number }>( + '/warehouse-express-mappings', + params, + ) +} + +export function createWarehouseExpressMapping(data: WarehouseExpressMappingPayload) { + return post<{ id: number }>('/warehouse-express-mappings', data) +} + +export function updateWarehouseExpressMapping(id: number, data: Partial) { + return put<{ id: number }>(`/warehouse-express-mappings/${id}`, data) +} + +export function deleteWarehouseExpressMapping(id: number) { + return del<{ id: number }>(`/warehouse-express-mappings/${id}`) +} diff --git a/frontend/src/store/menu.ts b/frontend/src/store/menu.ts index 39d3997..f792ace 100644 --- a/frontend/src/store/menu.ts +++ b/frontend/src/store/menu.ts @@ -42,6 +42,9 @@ const defaultMenus: MenuItem[] = [ children: [ { id: 61, parent_id: 6, name: '入库单', type: 2, path: '/inbound-order', icon: 'Bottom', permission: 'inboundOrder:list', component: 'views/InboundOrder/Index.vue', sort: 75, status: 1 }, { id: 62, parent_id: 6, name: '出库单', type: 2, path: '/outbound-order', icon: 'Top', permission: 'outboundOrder:list', component: 'views/OutboundOrder/Index.vue', sort: 70, status: 1 }, + { id: 65, parent_id: 6, name: '创建出库单', type: 2, path: '/outbound-order-create', icon: 'Plus', permission: 'outboundOrder:create', component: 'views/OutboundOrder/Create.vue', sort: 71, status: 1 }, + { id: 66, parent_id: 6, name: '创建入库单', type: 2, path: '/inbound-order-create', icon: 'Plus', permission: 'inboundOrder:create', component: 'views/InboundOrder/Create.vue', sort: 76, status: 1 }, + { id: 63, parent_id: 6, name: '出入库记录', type: 2, path: '/stock-record', icon: 'Finished', permission: 'stockRecord:list', component: 'views/StockRecord/Index.vue', sort: 65, status: 1 }, ], }, { diff --git a/frontend/src/utils/request.ts b/frontend/src/utils/request.ts index 74643dd..77277d7 100644 --- a/frontend/src/utils/request.ts +++ b/frontend/src/utils/request.ts @@ -90,19 +90,25 @@ service.interceptors.response.use( syncRefreshedToken(error.response?.headers) if (status === 401) { - // 登录失效:清空本地登录态(token 与所选主体)并返回首页 - // (未登录会被路由守卫转到登录页,登录成功后再回到首页) - clearToken() - usePrincipalStore().setCurrentId(null) - if (!redirectingToHome && router.currentRoute.value.name !== 'login') { - redirectingToHome = true - ElMessage.warning('登录状态已失效,请重新登录') - // 延后一个事件循环再跳转:避免在路由守卫的导航过程中插入新导航 - setTimeout(() => { - router.replace('/').finally(() => { - redirectingToHome = false - }) - }, 0) + const onLoginPage = router.currentRoute.value.name === 'login' + if (onLoginPage) { + // 登录页内(正在登录):直接提示后端返回的具体错误,如「账号或密码错误」 + ElMessage.error(message || '登录失败,请检查账号或密码') + } else { + // 登录失效:清空本地登录态(token 与所选主体)并返回首页 + // (未登录会被路由守卫转到登录页,登录成功后再回到首页) + clearToken() + usePrincipalStore().setCurrentId(null) + if (!redirectingToHome) { + redirectingToHome = true + ElMessage.warning(message || '登录状态已失效,请重新登录') + // 延后一个事件循环再跳转:避免在路由守卫的导航过程中插入新导航 + setTimeout(() => { + router.replace('/').finally(() => { + redirectingToHome = false + }) + }, 0) + } } } else { ElMessage.error(message) diff --git a/frontend/src/views/ExternalApi/Index.vue b/frontend/src/views/ExternalApi/Index.vue index 9b4fb92..ba4d79c 100644 --- a/frontend/src/views/ExternalApi/Index.vue +++ b/frontend/src/views/ExternalApi/Index.vue @@ -30,6 +30,14 @@ import { type WarehouseApiFieldGroup, } from '@/api/warehouseApi' import { getOutboundLogs, type OutboundLogItem } from '@/api/outboundLog' +import { + getWarehouseExpressMappings, + createWarehouseExpressMapping, + updateWarehouseExpressMapping, + deleteWarehouseExpressMapping, + type WarehouseExpressMappingItem, +} from '@/api/warehouseExpressMapping' +import { getExpressCompanyOptions, type ExpressCompanyOption } from '@/api/expressCompany' import SplitLayout from '@/components/SplitLayout.vue' import DataTable from '@/components/DataTable.vue' import ListPager from '@/components/ListPager.vue' @@ -118,6 +126,8 @@ async function switchWarehouse(id: number) { if (currentWarehouse.value?.id === id) return configLoadedId.value = null configList.value = [] + mappingLoadedId.value = null + mappingList.value = [] resetProductState() resetOutboundState() resetInventoryState() @@ -138,11 +148,128 @@ async function openConfigTab(row: WarehouseItem) { function handleDetailTabChange(name: string | number) { if (name === 'config' && configLoadedId.value !== currentWarehouse.value?.id) fetchConfigs() + if (name === 'express' && mappingLoadedId.value !== currentWarehouse.value?.id) fetchMappings() if (name === 'products' && productLoadedId.value !== currentWarehouse.value?.id) fetchProducts() if (name === 'inventory' && inventoryLoadedId.value !== currentWarehouse.value?.id) fetchInventory() if (name === 'logs' && outboundLoadedId.value !== currentWarehouse.value?.id) fetchOutboundLogs() } +/* -------------------- 快递映射(按仓库:外部自定义编码 → 默认快递编码) -------------------- */ +const mappingLoading = ref(false) +const mappingList = ref([]) +/** 已加载快递映射的仓库ID,避免切换标签页时重复请求 */ +const mappingLoadedId = ref(null) +/** 快递公司字典(供「默认快递」下拉) */ +const expressCompanies = ref([]) + +/** 拉取当前仓库的快递映射列表 */ +async function fetchMappings() { + const warehouseId = currentWarehouse.value?.id + if (!warehouseId) return + mappingLoading.value = true + try { + const res = await getWarehouseExpressMappings({ warehouse_id: warehouseId, page: 1, pageSize: 200 }) + // 请求期间若已切换仓库,丢弃过期结果 + if (currentWarehouse.value?.id !== warehouseId) return + mappingList.value = res.list + mappingLoadedId.value = warehouseId + } catch { + mappingList.value = [] + } finally { + mappingLoading.value = false + } +} + +async function ensureExpressCompanies() { + if (expressCompanies.value.length) return + try { expressCompanies.value = await getExpressCompanyOptions() } catch { expressCompanies.value = [] } +} + +const mappingDialogVisible = ref(false) +const mappingSubmitting = ref(false) +const mappingFormRef = ref() +const mappingEditId = ref(null) +const mappingForm = reactive({ + express_code: '', + custom_code: '', + status: 1, + remark: '', +}) +const mappingRules: FormRules = { + express_code: [{ required: true, message: '请选择默认快递', trigger: 'change' }], + custom_code: [{ required: true, message: '请填写自定义编码', trigger: 'blur' }], +} + +function openMappingCreate() { + mappingEditId.value = null + Object.assign(mappingForm, { express_code: '', custom_code: '', status: 1, remark: '' }) + ensureExpressCompanies() + mappingDialogVisible.value = true +} + +function openMappingEdit(row: WarehouseExpressMappingItem) { + mappingEditId.value = row.id + Object.assign(mappingForm, { + express_code: row.express_code, + custom_code: row.custom_code, + status: row.status, + remark: row.remark || '', + }) + ensureExpressCompanies() + mappingDialogVisible.value = true +} + +async function submitMappingForm() { + if (!mappingFormRef.value) return + await mappingFormRef.value.validate(async (valid) => { + if (!valid) return + const warehouseId = currentWarehouse.value?.id + if (!warehouseId) return + mappingSubmitting.value = true + try { + const payload = { + warehouse_id: warehouseId, + express_code: mappingForm.express_code, + custom_code: mappingForm.custom_code.trim().toUpperCase(), + status: mappingForm.status, + remark: mappingForm.remark || null, + } + if (mappingEditId.value == null) { + await createWarehouseExpressMapping(payload) + ElMessage.success('新增成功') + } else { + await updateWarehouseExpressMapping(mappingEditId.value, payload) + ElMessage.success('保存成功') + } + mappingDialogVisible.value = false + await fetchMappings() + } catch { + // 拦截器已提示 + } finally { + mappingSubmitting.value = false + } + }) +} + +async function handleMappingDelete(row: WarehouseExpressMappingItem) { + try { + await ElMessageBox.confirm( + `确定删除自定义编码「${row.custom_code}」的映射吗?删除后该编码将只能按快递公司字典兑底解析。`, + '删除映射', + { type: 'warning', confirmButtonText: '删除', cancelButtonText: '取消' }, + ) + } catch { + return + } + try { + await deleteWarehouseExpressMapping(row.id) + ElMessage.success('已删除') + await fetchMappings() + } catch { + // 拦截器已提示 + } +} + /* -------------------- 仓库 新增 / 编辑 -------------------- */ const dialogVisible = ref(false) const submitting = ref(false) @@ -870,6 +997,46 @@ onMounted(fetchList) + +
+ + +
+
+
+ + + + + + + + + + + + + + + 启用 + 禁用 + + + + + + + + @@ -1265,6 +1469,12 @@ onMounted(fetchList) .toolbar-right { margin-left: auto; } +/* 工具栏说明文案(与按钮同行,过长时自动换行) */ +.toolbar-hint { + margin-left: 12px; + font-size: 12px; + line-height: 1.4; +} /* 调用日志:展开详情与辅助样式 */ .log-detail { padding: 4px 12px; diff --git a/frontend/src/views/InboundOrder/Create.vue b/frontend/src/views/InboundOrder/Create.vue new file mode 100644 index 0000000..942f85b --- /dev/null +++ b/frontend/src/views/InboundOrder/Create.vue @@ -0,0 +1,547 @@ + + + + + diff --git a/frontend/src/views/InboundOrder/Index.vue b/frontend/src/views/InboundOrder/Index.vue index 361923c..68a481c 100644 --- a/frontend/src/views/InboundOrder/Index.vue +++ b/frontend/src/views/InboundOrder/Index.vue @@ -1,10 +1,10 @@ + + + + diff --git a/frontend/src/views/OutboundOrder/Index.vue b/frontend/src/views/OutboundOrder/Index.vue index 94e9fb2..b4e80e1 100644 --- a/frontend/src/views/OutboundOrder/Index.vue +++ b/frontend/src/views/OutboundOrder/Index.vue @@ -1,15 +1,16 @@ + + + +