feat(order): 订单列表展示电商平台,支持按电商平台筛选与平台单号批量查询
- 列表新增「电商平台」列(优先用落库的平台名称,缺失时按编码映射中文名),详情面板同口径展示 - 筛选新增电商平台多选(platform_codes)与平台单号批量精确匹配(platform_order_nos,最多 200 个) - 平台单号批量查询复用 MultiValueFilter:收起时英文逗号拼接、展开后一行一个,与店铺商品的商家编码一致 - 订单导出同步支持这两个筛选,并新增「电商平台」导出列 Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This commit is contained in:
parent
3a4eebb71d
commit
9a944be886
@ -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 备注 / 异常原因,模糊匹配
|
||||
|
||||
@ -101,6 +101,23 @@ function trimOrNull(value) {
|
||||
return text === '' ? null : text;
|
||||
}
|
||||
|
||||
/**
|
||||
* 多值筛选参数归一化(数组或逗号分隔字符串 → 去重后的字符串数组)
|
||||
* @param {*} value 原始参数
|
||||
* @param {number} max 最多保留的取值个数
|
||||
* @return {Array<String>} 归一化结果
|
||||
*/
|
||||
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) {
|
||||
|
||||
@ -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 ' +
|
||||
|
||||
@ -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<string, any> | null): string {
|
||||
return typeof value === 'string' ? value : ''
|
||||
}
|
||||
|
||||
/** 电商平台展示:优先用落库的平台名称,缺失时按编码(PDD / DYXD…)转中文名 */
|
||||
function platformTextOf(row: Record<string, any>): 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"
|
||||
/>
|
||||
</el-form-item>
|
||||
<el-form-item label="电商平台">
|
||||
<el-select
|
||||
v-model="query.platform_codes"
|
||||
multiple
|
||||
collapse-tags
|
||||
collapse-tags-tooltip
|
||||
filterable
|
||||
placeholder="全部"
|
||||
style="width: 190px"
|
||||
@change="search"
|
||||
>
|
||||
<el-option v-for="opt in PLATFORM_PRESETS" :key="opt.code" :label="opt.name" :value="opt.code" />
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item v-if="isDelivery" label="外部发货">
|
||||
<el-select v-model="query.external_send_status" placeholder="全部" clearable style="width: 150px" @change="search">
|
||||
<el-option
|
||||
@ -841,6 +873,14 @@ onBeforeUnmount(() => {
|
||||
<el-form-item label="来源订单号">
|
||||
<el-input v-model="query.parent_order_no" placeholder="上游 / 平台订单号" clearable style="width: 160px" @keyup.enter="search" />
|
||||
</el-form-item>
|
||||
<el-form-item label="平台单号">
|
||||
<MultiValueFilter
|
||||
v-model="query.platform_order_nos"
|
||||
placeholder="批量查询,多个平台单号"
|
||||
width="220px"
|
||||
@update:model-value="search"
|
||||
/>
|
||||
</el-form-item>
|
||||
<el-form-item label="店铺">
|
||||
<el-select v-model="query.shop_id" placeholder="全部" clearable style="width: 160px">
|
||||
<el-option v-for="shop in filters.shops" :key="shop.id" :label="shop.name" :value="shop.id" />
|
||||
@ -897,6 +937,9 @@ onBeforeUnmount(() => {
|
||||
<el-table-column label="店铺" width="120" show-overflow-tooltip>
|
||||
<template #default="{ row }">{{ row.shop_name || '-' }}</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="电商平台" width="110" show-overflow-tooltip>
|
||||
<template #default="{ row }">{{ platformTextOf(row) }}</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="货主" width="130" show-overflow-tooltip>
|
||||
<template #default="{ row }">{{ row.subsidiary_name || '-' }}</template>
|
||||
</el-table-column>
|
||||
@ -994,8 +1037,11 @@ onBeforeUnmount(() => {
|
||||
<el-descriptions-item v-if="platformOrderNoOf(detailRow)" label="平台订单号">
|
||||
{{ platformOrderNoOf(detailRow) }}
|
||||
</el-descriptions-item>
|
||||
<el-descriptions-item v-if="detailRow.is_external" label="来源平台">
|
||||
{{ platformNameOf(detailRow.source_platform_code) }}
|
||||
<el-descriptions-item
|
||||
v-if="detailRow.source_platform_name || detailRow.source_platform_code"
|
||||
label="电商平台"
|
||||
>
|
||||
{{ platformTextOf(detailRow) }}
|
||||
</el-descriptions-item>
|
||||
<el-descriptions-item label="状态">
|
||||
<el-tag size="small" :type="ORDER_STAGE_META[detailRow.status]?.tag">
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user