diff --git a/backend/app/controller/orderStatus.js b/backend/app/controller/orderStatus.js index 1130d42..3d99b8f 100644 --- a/backend/app/controller/orderStatus.js +++ b/backend/app/controller/orderStatus.js @@ -61,6 +61,8 @@ class OrderStatusController extends Controller { * @request query string order_no 订单号,模糊匹配 * @request query string parent_order_no 来源订单号,模糊匹配 * @request query integer shop_id 店铺ID + * @request query string platform_codes 电商平台编码,多选用逗号分隔(PDD / DYXD / SPH…,见系统预设平台编码) + * @request query string platform_order_nos 平台单号,多个精确匹配用逗号分隔(最多 200 个) * @request query string receiver 收货人,模糊匹配 * @request query string address 收货地址,模糊匹配 * @request query string remark 备注 / 异常原因,模糊匹配 diff --git a/backend/app/service/orderStatus.js b/backend/app/service/orderStatus.js index c979d51..35e8769 100644 --- a/backend/app/service/orderStatus.js +++ b/backend/app/service/orderStatus.js @@ -101,6 +101,23 @@ function trimOrNull(value) { return text === '' ? null : text; } +/** + * 多值筛选参数归一化(数组或逗号分隔字符串 → 去重后的字符串数组) + * @param {*} value 原始参数 + * @param {number} max 最多保留的取值个数 + * @return {Array} 归一化结果 + */ +function parseFilterValues(value, max = 200) { + const raw = Array.isArray(value) ? value : String(value == null ? '' : value).split(/[,,;;\n]/); + const list = []; + for (const item of raw) { + const text = String(item == null ? '' : item).trim(); + if (text && !list.includes(text)) list.push(text); + if (list.length >= max) break; + } + return list; +} + /** * 订单状态流转服务 * @@ -374,6 +391,12 @@ class OrderStatusService extends Service { if (remark) where.remark = { [Op.like]: `%${remark}%` }; if (p.shop_id !== undefined && p.shop_id !== '' && p.shop_id !== null) where.shop_id = Number(p.shop_id); + // 电商平台(系统预设编码,可多选)与平台单号(多个精确匹配,类似店铺商品的商家编码批量查询) + const platformCodes = parseFilterValues(p.platform_codes, 50).map(code => code.toUpperCase()); + if (platformCodes.length) where.source_platform_code = { [Op.in]: platformCodes }; + const platformOrderNos = parseFilterValues(p.platform_order_nos, 200).map(no => no.slice(0, 50)); + if (platformOrderNos.length) where.oaid_order_source_code = { [Op.in]: platformOrderNos }; + // 所在公司权限:仅列出自己所属公司(货主)的订单 const access = await this._scopeAccess(principalId); if (!access.isGroup) { diff --git a/backend/app/utils/exportDefs.js b/backend/app/utils/exportDefs.js index e5b7060..e16a766 100644 --- a/backend/app/utils/exportDefs.js +++ b/backend/app/utils/exportDefs.js @@ -285,6 +285,7 @@ const ORDER_COLUMNS = [ { key: 'order_type', header: '订单类型' }, { key: 'shop_id', header: '店铺ID' }, { key: 'shop_nick', header: '店铺名称' }, + { key: 'source_platform_name', header: '电商平台' }, { key: 'subsidiary_name', header: '货主' }, { key: 'warehouse_id', header: '仓库ID' }, { key: 'warehouse_code', header: '仓库编码' }, @@ -743,6 +744,8 @@ const EXPORT_TYPES = { { key: 'keyword', label: '关键词', type: 'text', placeholder: '订单号 / 来源订单号 / 收货人 / 地址' }, { key: 'order_no', label: '订单号', type: 'text', placeholder: '支持模糊匹配' }, { key: 'parent_order_no', label: '来源订单号', type: 'text', placeholder: '支持模糊匹配' }, + { key: 'platform_codes', label: '电商平台', type: 'select', options: PLATFORM_TYPE_OPTIONS, multiple: true }, + { key: 'platform_order_nos', label: '平台单号', type: 'text', placeholder: '多个用英文逗号分隔(精确匹配)' }, { key: 'receiver', label: '收货人', type: 'text' }, { key: 'address', label: '收货地址', type: 'text' }, { key: 'remark', label: '备注', type: 'text' }, @@ -785,6 +788,9 @@ const EXPORT_TYPES = { .to('created_at', f.created_to) .from('archived_at', f.archived_from) .to('archived_at', f.archived_to); + // 电商平台(多选)与平台单号(多个精确匹配),与列表接口同口径 + whereIn(wh, 't.source_platform_code', csvValues(f.platform_codes, 50).map(code => code.toUpperCase())); + whereIn(wh, 't.oaid_order_source_code', csvValues(f.platform_order_nos, 200)); if (String(f.exclude_unbound) === '1') { wh.raw( 'NOT EXISTS (SELECT 1 FROM order_status_items oi WHERE oi.order_id = t.id ' + diff --git a/frontend/src/views/Order/StatusPanel.vue b/frontend/src/views/Order/StatusPanel.vue index 1e7eb3a..4c9b663 100644 --- a/frontend/src/views/Order/StatusPanel.vue +++ b/frontend/src/views/Order/StatusPanel.vue @@ -17,7 +17,8 @@ import { import { DEFAULT_PAGE_SIZE, useListPage } from '@/composables/useListPage' import { useOrderSyncTask } from '@/composables/useOrderSyncTask' import { formatDateTime } from '@/utils/datetime' -import { platformNameOf } from '@/constants/platform' +import { PLATFORM_PRESETS, platformNameOf } from '@/constants/platform' +import MultiValueFilter from '@/components/MultiValueFilter.vue' import { ORDER_STAGE_META, archiveOrders, @@ -75,6 +76,10 @@ const query = reactive({ order_no: '', parent_order_no: '', shop_id: '' as number | '', + /** 电商平台(系统预设编码,多选) */ + platform_codes: [] as string[], + /** 平台单号(多个精确匹配,支持批量粘贴) */ + platform_order_nos: [] as string[], receiver: '', address: '', remark: '', @@ -124,6 +129,8 @@ const { loading, list, total, elapsed, fetchList, search, handlePageChange, hand if (query.order_no) params.order_no = query.order_no.trim() if (query.parent_order_no) params.parent_order_no = query.parent_order_no.trim() if (query.shop_id !== '') params.shop_id = query.shop_id + if (query.platform_codes.length) params.platform_codes = query.platform_codes.join(',') + if (query.platform_order_nos.length) params.platform_order_nos = query.platform_order_nos.join(',') if (query.receiver) params.receiver = query.receiver.trim() if (query.address) params.address = query.address.trim() if (query.remark) params.remark = query.remark.trim() @@ -149,6 +156,8 @@ function reset() { query.order_no = '' query.parent_order_no = '' query.shop_id = '' + query.platform_codes = [] + query.platform_order_nos = [] query.receiver = '' query.address = '' query.remark = '' @@ -167,6 +176,8 @@ const exportFilters = computed(() => ({ address: query.address.trim(), remark: query.remark.trim(), shop_id: query.shop_id, + platform_codes: query.platform_codes.join(','), + platform_order_nos: query.platform_order_nos.join(','), created_from: query.createdRange[0], created_to: query.createdRange[1], archived_from: query.archivedRange[0], @@ -687,6 +698,13 @@ function platformOrderNoOf(row: Record | null): string { return typeof value === 'string' ? value : '' } +/** 电商平台展示:优先用落库的平台名称,缺失时按编码(PDD / DYXD…)转中文名 */ +function platformTextOf(row: Record): string { + const name = String(row.source_platform_name || '').trim() + if (name) return name + return platformNameOf(row.source_platform_code as string | null | undefined) +} + /** 行金额 = 数量 × 单价 */ function lineAmount(line: OrderItemLine): string { const qty = Number(line.plan_qty || 0) @@ -817,6 +835,20 @@ onBeforeUnmount(() => { style="width: 230px" /> + + + + + { + + + @@ -897,6 +937,9 @@ onBeforeUnmount(() => { + + + @@ -994,8 +1037,11 @@ onBeforeUnmount(() => { {{ platformOrderNoOf(detailRow) }} - - {{ platformNameOf(detailRow.source_platform_code) }} + + {{ platformTextOf(detailRow) }}