From af865de6fcf1b73547cfa4a31a796eefdacdb609 Mon Sep 17 00:00:00 2001 From: yin <3313488199@qq.com> Date: Tue, 7 Apr 2026 18:27:40 +0800 Subject: [PATCH] =?UTF-8?q?4=E6=9C=887=E6=97=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/api/storeWarehouse.ts | 117 ++- src/test.txt | 2 + src/utils/request.ts | 39 +- .../storage/receiving/component/Product.vue | 116 --- src/views/store/component/detail.vue | 219 ++-- src/views/store/component/log.vue | 180 ++++ src/views/store/index.vue | 889 +++++++++++++--- src/views/store/store-config.ts | 99 +- src/需求文档.txt | 959 ++++++++++++------ 9 files changed, 1934 insertions(+), 686 deletions(-) create mode 100644 src/test.txt create mode 100644 src/views/store/component/log.vue diff --git a/src/api/storeWarehouse.ts b/src/api/storeWarehouse.ts index 11125a39..3e2d733c 100644 --- a/src/api/storeWarehouse.ts +++ b/src/api/storeWarehouse.ts @@ -25,6 +25,8 @@ export function storeWarehouseList(data: { /** 发起/预览/确认签约 */ export function storeWarehouseSign(data: { + store_id?: number + warehouse_id?: number temp_code?: string action?: 'preview' | 'confirm' counterparty_id?: number @@ -45,8 +47,7 @@ export function storeWarehouseSign(data: { /** 修改签约关系使用状态 */ export function storeWarehouseUnbind(data: { - id?: number - counterparty_id?: number + id: number use_status?: number }) { return request({ @@ -64,8 +65,7 @@ export function storeWarehouseUnbind(data: { /** 修改签约备注 */ export function storeWarehouseRename(data: { - id?: number - counterparty_id?: number + id: number remask: string }) { return request({ @@ -81,17 +81,15 @@ export function storeWarehouseRename(data: { } as any) } -/** 查询签约关系下的奇门接口配置列表 */ -export function storeWarehouseListQimenConfig(data: { - id?: number - counterparty_id?: number - interface_type_id?: number +/** 读取签约策略配置 */ +export function storeWarehouseGetPolicyConfig(data: { + id: number }) { return request({ url: '/system', method: 'post', params: { - method: 'storeWarehouse.store.listQimenConfig', + method: 'storeWarehouse.store.getPolicyConfig', v, timestamp: new Date().getTime() }, @@ -100,19 +98,91 @@ export function storeWarehouseListQimenConfig(data: { } as any) } -/** 保存奇门接口配置(新增或更新) */ -export function storeWarehouseSaveQimenConfig(data: { - id?: number - counterparty_id?: number +/** 获取签约策略可配置字段元信息列表 */ +export function storeWarehouseGetPolicyConfigFields() { + return request({ + url: '/system', + method: 'post', + params: { + method: 'storeWarehouse.store.getPolicyConfigFields', + v, + timestamp: new Date().getTime() + }, + data: {}, + isSystemApi: true + } as any) +} + +/** 保存签约策略配置 */ +export function storeWarehouseSavePolicyConfig(data: { + id: number + policy_config: Record +}) { + return request({ + url: '/system', + method: 'post', + params: { + method: 'storeWarehouse.store.savePolicyConfig', + v, + timestamp: new Date().getTime() + }, + data, + isSystemApi: true + } as any) +} + +/** 人工调整签约关系下的面单余额并记录变更日志 */ +export function storeWarehouseAdjustPrintQuantity(data: { + id: number + change_quantity: number + reason: string + business_type?: string + business_id?: number +}) { + return request({ + url: '/system', + method: 'post', + params: { + method: 'storeWarehouse.store.adjustPrintQuantity', + v, + timestamp: new Date().getTime() + }, + data, + isSystemApi: true + } as any) +} + + +/** 查询签约关系下的奇门接口配置列表 */ +export function listApiConfig(data: { + id: number interface_type_id?: number - app_name?: string - qimen_app_key: string - qimen_customer_id: string - qimen_warehouse_code: string +}) { + return request({ + url: '/system', + method: 'post', + params: { + method: 'storeWarehouse.store.listApiConfig', + v, + timestamp: new Date().getTime() + }, + data, + isSystemApi: true + } as any) +} + +/** 保存接口配置(新增或更新) + * - QM_WMS 类型:须填写 qimen_app_key / qimen_customer_id / qimen_warehouse_code + * - OPEN_API 类型:系统自动生成 self_app_key / self_app_secret,无需传入奇门字段 + */ +export function saveApiConfig(data: { + id: number + interface_type_id: number + app_name: string + qimen_app_key?: string + qimen_customer_id?: string + qimen_warehouse_code?: string api_version?: string - sign_method?: string - rate_limit?: number - timeout_seconds?: number contact_person?: string contact_phone?: string email?: string @@ -122,7 +192,7 @@ export function storeWarehouseSaveQimenConfig(data: { url: '/system', method: 'post', params: { - method: 'storeWarehouse.store.saveQimenConfig', + method: 'storeWarehouse.store.saveApiConfig', v, timestamp: new Date().getTime() }, @@ -133,8 +203,7 @@ export function storeWarehouseSaveQimenConfig(data: { /** 删除签约关系上的奇门接口配置 */ export function storeWarehouseDeleteQimenConfig(data: { - id?: number - counterparty_id?: number + id: number interface_type_id?: number }) { return request({ diff --git a/src/test.txt b/src/test.txt new file mode 100644 index 00000000..3e1e463e --- /dev/null +++ b/src/test.txt @@ -0,0 +1,2 @@ +接口文档更新: +[{"version":"2026.04.07-system-01","date":"2026-04-07","summary":"修正 warehouse.getAreaRacks 的鉴权/权限链路文档,明确该接口需要登录并走权限校验。","methods":["warehouse.getAreaRacks"],"notes":["对齐当前 system 文档中的 isNeedAuth=true、isNeedLogin=true。","用于补充该接口权限链路修正文档的历史上下文,不改变 methods/system.json 的 SSOT 角色。"]},{"version":"2026.04.07-system-02","date":"2026-04-07","summary":"补充签约配置相关接口文档,覆盖策略字段元信息查询与面单数量人工调整。","methods":["storeWarehouse.store.getPolicyConfigFields","storeWarehouse.store.adjustPrintQuantity"],"notes":["getPolicyConfigFields 说明为获取签约策略可配置字段元信息列表。","adjustPrintQuantity 说明为人工调整签约关系下的面单余额并记录变更日志,并明确 id、change_quantity、reason 等关键入参。"]},{"version":"2026.04.07-system-03","date":"2026-04-07","summary":"对外命名从 qimenConfig 收口为 apiConfig,并在接口配置文档中强调 interface_type_id 校验。","methods":["storeWarehouse.store.listApiConfig","storeWarehouse.store.saveApiConfig","storeWarehouse.store.deleteQimenConfig"],"notes":["文档对外统一使用 apiConfig / api_config 命名,减少 qimenConfig 历史别名歧义。","saveApiConfig 要求 interface_type_id 为必填且必须指向已存在的 wms_interface_type 记录。","listApiConfig / deleteQimenConfig 同步补充 interface_type_id 字段说明。"]},{"version":"2026.04.07-system-04","date":"2026-04-07","summary":"补充 /api/docs 文档体验增强说明,新增查看变更记录与查看原文 JSON 的入口说明。","methods":["/api/docs","/api/docs/:docName","/api/docs/:docName/raw","/api/docs/:docName/changes"],"notes":["sidecar 变更数组用于承载文档历史说明,不替代 methods/system.json 作为 SSOT。","原文 JSON 入口继续用于直接查看当前生效文档。"]}] \ No newline at end of file diff --git a/src/utils/request.ts b/src/utils/request.ts index 39a39876..e8aab9c8 100644 --- a/src/utils/request.ts +++ b/src/utils/request.ts @@ -4,6 +4,7 @@ import { getToken, setToken, removeToken } from '@/utils/auth' import router from '@/router' +import { useUserStore } from '@/stores/modules/user' // create an axios instance const service = axios.create({ @@ -82,18 +83,40 @@ service.interceptors.response.use( // 强制转换为小写键以进行不区分大小写的查找 const headers = response.headers const res = response.data + // console.log('响应开始') - // axios 的 headers 对象通常已经处理过大小写,但为了保险起见,检查多种可能的键名 - const newToken = headers['new-token'] || headers['new-authorization'] || headers['authorization'] || headers['Authorization']; - - if (newToken) { - // 提取 Bearer 之后的 token 字符串 - const tokenValue = newToken.startsWith('Bearer ') ? newToken.substring(7) : newToken + const getHeader = (key: string): string | null => { + if (typeof headers.get === 'function') { + // console.log(`尝试从 headers.get('${key}') 获取 token`) + const val = headers.get(key) + return val ? String(val) : null + } + return headers[key.toLowerCase()] || headers[key] || null + } + + const rawToken = getHeader('authorization') || getHeader('Authorization') || getHeader('new-authorization') + + // console.log('检测token:', rawToken) + + if (rawToken) { + // 提取 Bearer 之后的 token 字符串(大小写不敏感) + let tokenValue = rawToken.toLowerCase().startsWith('bearer ') + ? rawToken.substring(7).trim() + : rawToken.trim() + if (tokenValue && tokenValue !== getToken()) { - console.log('检测到新 Token,正在更新存储...'); + console.log('检测到新 Token,正在更新存储...') + // 同步更新 localStorage 和 axios 默认头 setToken(tokenValue) - // 同步更新当前实例的默认请求头,确保后续请求立即生效 + // console.log('Token 已更新:', tokenValue) service.defaults.headers.common['Authorization'] = `Bearer ${tokenValue}` + // 同步更新 Pinia user store(懒获取,避免 Pinia 未初始化时报错) + try { + const userStore = useUserStore() + userStore.updateToken(tokenValue) + } catch (_) { + // Pinia 未就绪时静默忽略,localStorage 已更新,下次请求会从 getToken() 读取 + } } } diff --git a/src/views/storage/receiving/component/Product.vue b/src/views/storage/receiving/component/Product.vue index ab9d80e7..49783fde 100644 --- a/src/views/storage/receiving/component/Product.vue +++ b/src/views/storage/receiving/component/Product.vue @@ -246,122 +246,6 @@ const props = defineProps<{ row?: any }>() -// 模拟数据 -// const mockProductData = [ -// { -// id: 1, -// receiving_number: 'RCV202601180001', -// item_name: '商品A - 测试商品', -// barcodes: '6901234567890', -// product_snapshot: '{"id": null, "name": "商品A - 测试商品", "barcode": "6901234567890", "spec": "500g/袋"}', -// system_product_id: null, -// actual_quantity: 20, -// box_quantity: 2, -// boxes_per_pallet: 10, -// pallet_quantity: 0, -// receiving_time: '2026-01-18 22:43:42', -// receiving_status_display: '已完成', -// storage_status: '未入库', -// stored_quantity: 0, -// batch_number: 'BATCH20231215A', -// production_date: '2023-12-01', -// expiry_date: '2024-12-01', -// remark: '商品A测试明细 - 未匹配', -// box_length: 40, -// box_width: 30, -// box_height: 25, -// weight: 10.5, -// space_id: 'A-01-01', -// creator_id: 'EMP001', -// updated_at_display: '2026-01-18 22:43:42', -// created_at_display: '2026-01-18 22:43:42' -// }, -// { -// id: 2, -// receiving_number: 'RCV202601180001', -// item_name: '商品B - 进口商品', -// barcodes: '8801234567890', -// product_snapshot: '{"id": null, "name": "商品B - 进口商品", "barcode": "8801234567890", "origin": "日本", "spec": "1kg/盒"}', -// system_product_id: null, -// actual_quantity: 15, -// box_quantity: 1, -// boxes_per_pallet: 15, -// pallet_quantity: 1, -// receiving_time: '2026-01-18 22:43:42', -// receiving_status_display: '已完成', -// storage_status: '未入库', -// stored_quantity: 0, -// batch_number: 'BATCH20231215B', -// production_date: '2023-11-15', -// expiry_date: '2024-11-15', -// remark: '商品B测试明细 - 未匹配', -// box_length: 50, -// box_width: 40, -// box_height: 30, -// weight: 15.0, -// space_id: 'B-02-05', -// creator_id: 'EMP001', -// updated_at_display: '2026-01-18 22:43:42', -// created_at_display: '2026-01-18 22:43:42' -// }, -// { -// id: 3, -// receiving_number: 'RCV202601180001', -// item_name: '商品C - 电子商品', -// barcodes: '4901234567890', -// product_snapshot: '{"id": null, "name": "商品C - 电子商品", "barcode": "4901234567890", "brand": "索尼", "model": "X-100"}', -// system_product_id: 152656, -// actual_quantity: 15, -// box_quantity: 2, -// boxes_per_pallet: 8, -// pallet_quantity: 1, -// receiving_time: '2026-01-18 21:43:42', -// receiving_status_display: '已完成', -// storage_status: '部分入库', -// stored_quantity: 5, -// batch_number: 'BATCH20231215C', -// production_date: '2023-10-01', -// expiry_date: '2025-10-01', -// remark: '商品C测试明细 - 未匹配', -// box_length: 30, -// box_width: 20, -// box_height: 15, -// weight: 5.2, -// space_id: 'C-01-12', -// creator_id: 'EMP001', -// updated_at_display: '2026-01-18 22:43:42', -// created_at_display: '2026-01-18 22:43:42' -// }, -// { -// id: 48, -// receiving_number: 'RCV2026020100002', -// item_name: 'MOODAMOR绮梦茉莉香型香水', -// barcodes: '6942233906190', -// product_snapshot: '{"store_id":1000166,"store_name":"花颜物语","updated_at":"2026-02-02T08:37:06.691Z"}', -// system_product_id: null, -// actual_quantity: 1000, -// box_quantity: 10, -// boxes_per_pallet: 100, -// pallet_quantity: 20, -// receiving_time: '2026-02-02 07:10:26', -// receiving_status_display: '收货中', -// storage_status: '未入库', -// stored_quantity: 0, -// batch_number: '20260202', -// production_date: '2025-12-01', -// expiry_date: '2028-12-01', -// remark: '1561534', -// box_length: 45, -// box_width: 35, -// box_height: 30, -// weight: 12.8, -// space_id: 'D-05-01', -// creator_id: 'EMP030', -// updated_at_display: '2026-02-02 13:24:43', -// created_at_display: '2026-02-02 07:10:26' -// } -// ] - const tableData = ref([]) const multipleSelection = ref([]) const saveLoading = ref(false) diff --git a/src/views/store/component/detail.vue b/src/views/store/component/detail.vue index f72fc0be..2c34086b 100644 --- a/src/views/store/component/detail.vue +++ b/src/views/store/component/detail.vue @@ -1,85 +1,170 @@ - \ No newline at end of file diff --git a/src/views/store/component/log.vue b/src/views/store/component/log.vue new file mode 100644 index 00000000..3f5dfa98 --- /dev/null +++ b/src/views/store/component/log.vue @@ -0,0 +1,180 @@ + + + + + diff --git a/src/views/store/index.vue b/src/views/store/index.vue index 557659fd..298c7dec 100644 --- a/src/views/store/index.vue +++ b/src/views/store/index.vue @@ -6,6 +6,7 @@ title="货主筛选" :preset-tree="presetTree" :available-fields="availableFields" + :initial-conditions="{ use_status: 1 }" @condition-change="handleConditionChange" @reset="handleReset" /> @@ -19,6 +20,9 @@ 刷新 + + {{ balanceVisible ? '隐藏余额' : '显示余额' }} +
+