mirror of
https://gitee.com/qqtt-ah/ecom-dmb.git
synced 2026-11-25 06:29:20 +08:00
refactor: 调整订单表
This commit is contained in:
@@ -39,10 +39,12 @@ export namespace OrderDTO {
|
||||
platformOrderNo?: string;
|
||||
/** 订单状态码 */
|
||||
status: string;
|
||||
/** 实付/商家实收金额 */
|
||||
/** 买家实付金额 */
|
||||
payAmount: number;
|
||||
/** 兼容旧字段名(后端 JsonAlias) */
|
||||
/** 商家实收金额 */
|
||||
receivedAmount?: number;
|
||||
/** 平台服务费 */
|
||||
serviceFee?: number;
|
||||
/** 下单时间 */
|
||||
orderTime: string;
|
||||
/** 订单明细(未传时后端用扁平字段合成一行) */
|
||||
@@ -77,10 +79,12 @@ export namespace OrderDTO {
|
||||
platformOrderNo?: string;
|
||||
/** 订单状态码 */
|
||||
status?: string;
|
||||
/** 实付/商家实收金额 */
|
||||
/** 买家实付金额 */
|
||||
payAmount: number;
|
||||
/** 兼容旧字段名 */
|
||||
/** 商家实收金额 */
|
||||
receivedAmount?: number;
|
||||
/** 平台服务费 */
|
||||
serviceFee?: number;
|
||||
/** 下单时间 */
|
||||
orderTime: string;
|
||||
/** 订单明细(全量替换) */
|
||||
@@ -102,6 +106,8 @@ export namespace OrderDTO {
|
||||
export interface Filters {
|
||||
/** 店铺 ID */
|
||||
shopId?: number;
|
||||
/** 平台代码(如 pdd/taobao/jd) */
|
||||
platformCode?: string;
|
||||
/** 平台订单号(默认前缀匹配;含 %/_ 时全模糊) */
|
||||
platformOrderNo?: string;
|
||||
/** 订单状态码 */
|
||||
|
||||
@@ -59,6 +59,8 @@ export namespace OrderVO {
|
||||
shopName: string;
|
||||
/** 平台代码 */
|
||||
platformCode?: string;
|
||||
/** 平台名称(后端由 platformCode 解析) */
|
||||
platformLabel?: string;
|
||||
/** 平台订单号 */
|
||||
platformOrderNo: string;
|
||||
/** 订单状态码(如 PENDING_SHIPMENT) */
|
||||
@@ -69,18 +71,50 @@ export namespace OrderVO {
|
||||
statusColor?: string;
|
||||
/** 来源 */
|
||||
source?: string;
|
||||
/** 实付/商家实收金额 */
|
||||
/** 买家实付金额 */
|
||||
payAmount: number;
|
||||
/** 兼容旧字段名(后端 JSON 别名) */
|
||||
/** 商家实收金额(=实付-服务费+平台优惠) */
|
||||
receivedAmount?: number;
|
||||
/** 平台服务费 */
|
||||
serviceFee?: number;
|
||||
/** 商品金额合计 */
|
||||
goodsAmount?: number;
|
||||
/** 折扣金额合计 */
|
||||
discountAmount?: number;
|
||||
/** 邮费 */
|
||||
postage?: number;
|
||||
/** 平台优惠 */
|
||||
platformDiscount?: number;
|
||||
/** 商家优惠 */
|
||||
sellerDiscount?: number;
|
||||
/** 快递公司编码 */
|
||||
logisticsId?: string;
|
||||
/** 快递运单号 */
|
||||
trackingNumber?: string;
|
||||
/** 下单时间 */
|
||||
orderTime: string;
|
||||
/** 支付时间 */
|
||||
payTime?: string;
|
||||
/** 成交时间 */
|
||||
confirmTime?: string;
|
||||
/** 发货时间 */
|
||||
shippingTime?: string;
|
||||
/** 签收时间 */
|
||||
receiveTime?: string;
|
||||
/** 省份 */
|
||||
province?: string;
|
||||
/** 城市 */
|
||||
city?: string;
|
||||
/** 区县 */
|
||||
town?: string;
|
||||
/** 收件人姓名脱敏 */
|
||||
receiverNameMask?: string;
|
||||
/** 收件人手机脱敏 */
|
||||
receiverPhoneMask?: string;
|
||||
/** 收件地址脱敏 */
|
||||
receiverAddressMask?: string;
|
||||
/** 买家留言 */
|
||||
buyerMemo?: string;
|
||||
/** 创建时间 */
|
||||
createTime: string;
|
||||
/** 更新时间 */
|
||||
@@ -95,6 +129,10 @@ export namespace OrderVO {
|
||||
importTaskId?: number;
|
||||
/** 确认(0-否 1-是) */
|
||||
confirm?: number;
|
||||
/** 平台侧订单更新时间 */
|
||||
platformUpdatedAt?: string;
|
||||
/** 最近一次转换时间 */
|
||||
lastMappedTime?: string;
|
||||
/** 明细行数(列表汇总) */
|
||||
itemCount?: number;
|
||||
/** 首行链接商品名(列表汇总) */
|
||||
@@ -107,7 +145,7 @@ export namespace OrderVO {
|
||||
}
|
||||
|
||||
/**
|
||||
* 订单字段信息 VO(导入映射;fieldName 仍用 received_amount,后端映射 payAmount)
|
||||
* 订单字段信息 VO(导入映射;fieldName 用 received_amount 表示商家实收)
|
||||
*/
|
||||
export namespace OrderFieldVO {
|
||||
/** 订单字段信息 */
|
||||
|
||||
@@ -33,6 +33,8 @@ export namespace PddOrderVO {
|
||||
postage?: number;
|
||||
platformDiscount?: number;
|
||||
sellerDiscount?: number;
|
||||
serviceFee?: number;
|
||||
serviceFeeDetail?: string;
|
||||
logisticsId?: number;
|
||||
trackingNumber?: string;
|
||||
createdTime?: string;
|
||||
|
||||
@@ -0,0 +1,69 @@
|
||||
<script lang="ts" setup>
|
||||
import { computed } from 'vue';
|
||||
|
||||
import { Tag } from 'ant-design-vue';
|
||||
|
||||
import {
|
||||
getPlatformLabel,
|
||||
getPlatformTagColor,
|
||||
} from '#/utils/platform-display';
|
||||
|
||||
defineOptions({ name: 'PlatformTag' });
|
||||
|
||||
const props = withDefaults(
|
||||
defineProps<{
|
||||
/** 平台代码(taobao/jd/pdd/...) */
|
||||
code?: null | string;
|
||||
/** 优先展示名(如后端 platformLabel / 字典 label) */
|
||||
label?: null | string;
|
||||
/** 无平台时是否显示「未关联平台」 */
|
||||
showEmpty?: boolean;
|
||||
size?: 'default' | 'small';
|
||||
}>(),
|
||||
{
|
||||
code: undefined,
|
||||
label: undefined,
|
||||
showEmpty: false,
|
||||
size: 'small',
|
||||
},
|
||||
);
|
||||
|
||||
const hasPlatform = computed(
|
||||
() => !!(props.code?.trim() || props.label?.trim()),
|
||||
);
|
||||
|
||||
const displayLabel = computed(() =>
|
||||
getPlatformLabel(props.code, props.label),
|
||||
);
|
||||
|
||||
const color = computed(() => getPlatformTagColor(props.code));
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<Tag
|
||||
v-if="hasPlatform"
|
||||
:color="color"
|
||||
:class="['platform-tag', size === 'small' ? 'platform-tag--sm' : '']"
|
||||
>
|
||||
{{ displayLabel }}
|
||||
</Tag>
|
||||
<Tag v-else-if="showEmpty" color="default" class="platform-tag platform-tag--sm">
|
||||
未关联平台
|
||||
</Tag>
|
||||
<span v-else class="platform-tag-empty">-</span>
|
||||
</template>
|
||||
|
||||
<style scoped>
|
||||
.platform-tag {
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
.platform-tag--sm {
|
||||
font-size: 12px;
|
||||
line-height: 18px;
|
||||
}
|
||||
|
||||
.platform-tag-empty {
|
||||
color: #bfbfbf;
|
||||
}
|
||||
</style>
|
||||
@@ -3,11 +3,25 @@
|
||||
*/
|
||||
import type { OrderItemVO, OrderVO } from '#/api/ecommerce/order';
|
||||
|
||||
/** 实付/商家实收(兼容 receivedAmount 别名) */
|
||||
/** 买家实付 */
|
||||
export function getOrderPayAmount(
|
||||
order: Pick<OrderVO.Info, 'payAmount'>,
|
||||
): number {
|
||||
return Number(order.payAmount ?? 0);
|
||||
}
|
||||
|
||||
/** 商家实收(缺省时回退实付,兼容旧数据) */
|
||||
export function getOrderReceivedAmount(
|
||||
order: Pick<OrderVO.Info, 'payAmount' | 'receivedAmount'>,
|
||||
): number {
|
||||
return Number(order.payAmount ?? order.receivedAmount ?? 0);
|
||||
return Number(order.receivedAmount ?? order.payAmount ?? 0);
|
||||
}
|
||||
|
||||
/** 平台服务费 */
|
||||
export function getOrderServiceFee(
|
||||
order: Pick<OrderVO.Info, 'serviceFee'>,
|
||||
): number {
|
||||
return Number(order.serviceFee ?? 0);
|
||||
}
|
||||
|
||||
/** 首行明细(列表/卡片单行展示) */
|
||||
|
||||
@@ -0,0 +1,69 @@
|
||||
/**
|
||||
* 电商平台展示:与后端 PlatformCode 枚举对齐,覆盖全部预置平台。
|
||||
* 文案以字典 API / 后端 platformLabel 为准;色板仅前端展示用。
|
||||
*/
|
||||
|
||||
export type PlatformTagColor =
|
||||
| 'blue'
|
||||
| 'cyan'
|
||||
| 'default'
|
||||
| 'error'
|
||||
| 'geekblue'
|
||||
| 'gold'
|
||||
| 'green'
|
||||
| 'lime'
|
||||
| 'magenta'
|
||||
| 'orange'
|
||||
| 'processing'
|
||||
| 'purple'
|
||||
| 'red'
|
||||
| 'success'
|
||||
| 'volcano'
|
||||
| 'warning';
|
||||
|
||||
export interface PlatformDisplayMeta {
|
||||
code: string;
|
||||
/** 默认中文名(字典未加载时回退) */
|
||||
label: string;
|
||||
color: PlatformTagColor;
|
||||
}
|
||||
|
||||
/** 与 PlatformCode 一一对应;未知 code 走 fallback */
|
||||
const PLATFORM_META: Record<string, PlatformDisplayMeta> = {
|
||||
taobao: { code: 'taobao', label: '淘宝', color: 'orange' },
|
||||
jd: { code: 'jd', label: '京东', color: 'red' },
|
||||
pdd: { code: 'pdd', label: '拼多多', color: 'volcano' },
|
||||
douyin: { code: 'douyin', label: '抖音', color: 'magenta' },
|
||||
kuaishou: { code: 'kuaishou', label: '快手', color: 'gold' },
|
||||
xiaohongshu: { code: 'xiaohongshu', label: '小红书', color: 'error' },
|
||||
tmall: { code: 'tmall', label: '天猫', color: 'red' },
|
||||
vip: { code: 'vip', label: '唯品会', color: 'purple' },
|
||||
suning: { code: 'suning', label: '苏宁', color: 'blue' },
|
||||
'1688': { code: '1688', label: '1688', color: 'cyan' },
|
||||
};
|
||||
|
||||
export function getPlatformMeta(code?: null | string): PlatformDisplayMeta | null {
|
||||
if (!code || !code.trim()) return null;
|
||||
const key = code.trim().toLowerCase();
|
||||
return PLATFORM_META[key] ?? null;
|
||||
}
|
||||
|
||||
export function getPlatformTagColor(code?: null | string): PlatformTagColor {
|
||||
return getPlatformMeta(code)?.color ?? 'default';
|
||||
}
|
||||
|
||||
/** 展示名:优先后端/字典 label,再本地映射,最后原 code */
|
||||
export function getPlatformLabel(
|
||||
code?: null | string,
|
||||
preferredLabel?: null | string,
|
||||
): string {
|
||||
if (preferredLabel && preferredLabel.trim()) return preferredLabel.trim();
|
||||
const meta = getPlatformMeta(code);
|
||||
if (meta) return meta.label;
|
||||
if (code && code.trim()) return code.trim();
|
||||
return '未关联平台';
|
||||
}
|
||||
|
||||
export function listBuiltinPlatformMetas(): PlatformDisplayMeta[] {
|
||||
return Object.values(PLATFORM_META);
|
||||
}
|
||||
+263
@@ -0,0 +1,263 @@
|
||||
<script lang="ts" setup>
|
||||
import type { OrderItemVO, OrderVO } from '#/api/ecommerce/order';
|
||||
|
||||
import { computed, ref } from 'vue';
|
||||
|
||||
import {
|
||||
Descriptions,
|
||||
DescriptionsItem,
|
||||
Drawer,
|
||||
Image,
|
||||
Table,
|
||||
Tag,
|
||||
message,
|
||||
} from 'ant-design-vue';
|
||||
|
||||
import { getOrderByIdApi } from '#/api/ecommerce/order';
|
||||
import PlatformTag from '#/components/platform/PlatformTag.vue';
|
||||
import {
|
||||
getOrderPayAmount,
|
||||
getOrderReceivedAmount,
|
||||
getOrderServiceFee,
|
||||
} from '#/utils/order-display';
|
||||
|
||||
defineOptions({ name: 'OrderDetailDrawer' });
|
||||
|
||||
const SOURCE_LABEL: Record<string, string> = {
|
||||
import: '导入',
|
||||
sync: '同步',
|
||||
manual: '手动',
|
||||
};
|
||||
|
||||
const openFlag = ref(false);
|
||||
const loading = ref(false);
|
||||
const detail = ref<null | OrderVO.Info>(null);
|
||||
|
||||
const itemColumns = [
|
||||
{ title: '商品', key: 'goods', dataIndex: 'linkProductName' },
|
||||
{
|
||||
title: '规格',
|
||||
dataIndex: 'linkSkuName',
|
||||
key: 'linkSkuName',
|
||||
ellipsis: true,
|
||||
},
|
||||
{ title: '数量', dataIndex: 'quantity', key: 'quantity', width: 70 },
|
||||
{ title: '单价', key: 'unitPrice', width: 100 },
|
||||
{ title: '行金额', key: 'lineAmount', width: 100 },
|
||||
{ title: '商品成本', key: 'productCost', width: 100 },
|
||||
{ title: '运费成本', key: 'shippingCost', width: 100 },
|
||||
{ title: '其他成本', key: 'otherCost', width: 100 },
|
||||
{
|
||||
title: 'SKU编码',
|
||||
dataIndex: 'skuCode',
|
||||
key: 'skuCode',
|
||||
ellipsis: true,
|
||||
},
|
||||
];
|
||||
|
||||
const moneyFields = computed(() => {
|
||||
const d = detail.value;
|
||||
if (!d) return [];
|
||||
return [
|
||||
{ label: '实付', value: getOrderPayAmount(d) },
|
||||
{ label: '服务费', value: getOrderServiceFee(d) },
|
||||
{ label: '商家实收', value: getOrderReceivedAmount(d) },
|
||||
{ label: '商品金额', value: d.goodsAmount },
|
||||
{ label: '折扣', value: d.discountAmount },
|
||||
{ label: '邮费', value: d.postage },
|
||||
{ label: '平台优惠', value: d.platformDiscount },
|
||||
{ label: '商家优惠', value: d.sellerDiscount },
|
||||
];
|
||||
});
|
||||
|
||||
function money(v?: null | number) {
|
||||
if (v == null || Number.isNaN(Number(v))) return '-';
|
||||
return `¥${Number(v).toFixed(2)}`;
|
||||
}
|
||||
|
||||
function sourceText(source?: string) {
|
||||
if (!source) return '-';
|
||||
return SOURCE_LABEL[source] ?? source;
|
||||
}
|
||||
|
||||
function itemTitle(item: OrderItemVO.Info) {
|
||||
return item.product?.name || item.linkProductName || '-';
|
||||
}
|
||||
|
||||
function itemSpec(item: OrderItemVO.Info) {
|
||||
return item.productSku?.name || item.linkSkuName || '-';
|
||||
}
|
||||
|
||||
async function open(id: number) {
|
||||
openFlag.value = true;
|
||||
loading.value = true;
|
||||
detail.value = null;
|
||||
try {
|
||||
detail.value = await getOrderByIdApi(id);
|
||||
} catch (error) {
|
||||
console.error(error);
|
||||
message.error('加载订单详情失败');
|
||||
openFlag.value = false;
|
||||
} finally {
|
||||
loading.value = false;
|
||||
}
|
||||
}
|
||||
|
||||
function close() {
|
||||
openFlag.value = false;
|
||||
}
|
||||
|
||||
defineExpose({ open, close });
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<Drawer
|
||||
v-model:open="openFlag"
|
||||
title="订单详情"
|
||||
width="780"
|
||||
destroy-on-close
|
||||
:loading="loading"
|
||||
>
|
||||
<template v-if="detail">
|
||||
<Descriptions bordered :column="2" size="small" class="mb-4">
|
||||
<DescriptionsItem label="平台订单号" :span="2">
|
||||
{{ detail.platformOrderNo || '-' }}
|
||||
</DescriptionsItem>
|
||||
<DescriptionsItem label="店铺">
|
||||
{{ detail.shopName || detail.shop?.name || `店铺#${detail.shopId}` }}
|
||||
</DescriptionsItem>
|
||||
<DescriptionsItem label="平台">
|
||||
<PlatformTag
|
||||
:code="detail.platformCode"
|
||||
:label="detail.platformLabel"
|
||||
show-empty
|
||||
/>
|
||||
</DescriptionsItem>
|
||||
<DescriptionsItem label="订单状态">
|
||||
<Tag :color="detail.statusColor || 'blue'">
|
||||
{{ detail.statusLabel || detail.status || '-' }}
|
||||
</Tag>
|
||||
</DescriptionsItem>
|
||||
<DescriptionsItem label="来源">
|
||||
{{ sourceText(detail.source) }}
|
||||
</DescriptionsItem>
|
||||
<DescriptionsItem label="运单号">
|
||||
{{ detail.trackingNumber || '-' }}
|
||||
</DescriptionsItem>
|
||||
<DescriptionsItem label="快递编码">
|
||||
{{ detail.logisticsId || '-' }}
|
||||
</DescriptionsItem>
|
||||
<DescriptionsItem label="下单时间">
|
||||
{{ detail.orderTime || '-' }}
|
||||
</DescriptionsItem>
|
||||
<DescriptionsItem label="支付时间">
|
||||
{{ detail.payTime || '-' }}
|
||||
</DescriptionsItem>
|
||||
<DescriptionsItem label="成交时间">
|
||||
{{ detail.confirmTime || '-' }}
|
||||
</DescriptionsItem>
|
||||
<DescriptionsItem label="发货时间">
|
||||
{{ detail.shippingTime || '-' }}
|
||||
</DescriptionsItem>
|
||||
<DescriptionsItem label="签收时间">
|
||||
{{ detail.receiveTime || '-' }}
|
||||
</DescriptionsItem>
|
||||
<DescriptionsItem label="最近转换">
|
||||
{{ detail.lastMappedTime || '-' }}
|
||||
</DescriptionsItem>
|
||||
<DescriptionsItem
|
||||
v-for="item in moneyFields"
|
||||
:key="item.label"
|
||||
:label="item.label"
|
||||
>
|
||||
{{ money(item.value) }}
|
||||
</DescriptionsItem>
|
||||
<DescriptionsItem label="收件人">
|
||||
{{ detail.receiverNameMask || '-' }}
|
||||
</DescriptionsItem>
|
||||
<DescriptionsItem label="手机">
|
||||
{{ detail.receiverPhoneMask || '-' }}
|
||||
</DescriptionsItem>
|
||||
<DescriptionsItem label="地区" :span="2">
|
||||
{{
|
||||
[detail.province, detail.city, detail.town]
|
||||
.filter(Boolean)
|
||||
.join(' / ') || '-'
|
||||
}}
|
||||
</DescriptionsItem>
|
||||
<DescriptionsItem label="地址" :span="2">
|
||||
{{ detail.receiverAddressMask || '-' }}
|
||||
</DescriptionsItem>
|
||||
<DescriptionsItem label="买家留言" :span="2">
|
||||
{{ detail.buyerMemo || '-' }}
|
||||
</DescriptionsItem>
|
||||
<DescriptionsItem label="备注" :span="2">
|
||||
{{ detail.remark || '-' }}
|
||||
</DescriptionsItem>
|
||||
</Descriptions>
|
||||
|
||||
<div class="mb-2 font-medium">商品明细</div>
|
||||
<Table
|
||||
:columns="itemColumns"
|
||||
:data-source="detail.items || []"
|
||||
:pagination="false"
|
||||
:row-key="(r: OrderItemVO.Info) => r.id ?? r.lineNo"
|
||||
size="small"
|
||||
bordered
|
||||
:scroll="{ x: 900 }"
|
||||
>
|
||||
<template #bodyCell="{ column, record }">
|
||||
<template v-if="column.key === 'goods'">
|
||||
<div class="goods-row">
|
||||
<Image
|
||||
v-if="record.goodsImg"
|
||||
:src="record.goodsImg"
|
||||
:width="36"
|
||||
:height="36"
|
||||
/>
|
||||
<span>{{ itemTitle(record) }}</span>
|
||||
</div>
|
||||
</template>
|
||||
<template v-else-if="column.key === 'linkSkuName'">
|
||||
{{ itemSpec(record) }}
|
||||
</template>
|
||||
<template v-else-if="column.key === 'unitPrice'">
|
||||
{{ money(record.unitPrice) }}
|
||||
</template>
|
||||
<template v-else-if="column.key === 'lineAmount'">
|
||||
{{ money(record.lineAmount) }}
|
||||
</template>
|
||||
<template v-else-if="column.key === 'productCost'">
|
||||
{{ money(record.productCost) }}
|
||||
</template>
|
||||
<template v-else-if="column.key === 'shippingCost'">
|
||||
{{ money(record.shippingCost) }}
|
||||
</template>
|
||||
<template v-else-if="column.key === 'otherCost'">
|
||||
{{ money(record.otherCost) }}
|
||||
</template>
|
||||
</template>
|
||||
</Table>
|
||||
</template>
|
||||
</Drawer>
|
||||
</template>
|
||||
|
||||
<style scoped>
|
||||
.mb-4 {
|
||||
margin-bottom: 16px;
|
||||
}
|
||||
|
||||
.mb-2 {
|
||||
margin-bottom: 8px;
|
||||
}
|
||||
|
||||
.font-medium {
|
||||
font-weight: 500;
|
||||
}
|
||||
|
||||
.goods-row {
|
||||
display: flex;
|
||||
gap: 8px;
|
||||
align-items: center;
|
||||
}
|
||||
</style>
|
||||
+135
-49
@@ -5,7 +5,7 @@ import type {
|
||||
ProductSkuVO,
|
||||
} from '#/api/ecommerce/product-sku/types';
|
||||
import type { ProductDTO, ProductVO } from '#/api/ecommerce/product/types';
|
||||
import type { ShopVO } from '#/api/ecommerce/shop/types';
|
||||
import type { ShopDTO, ShopVO } from '#/api/ecommerce/shop/types';
|
||||
import type { PageQueryDTO } from '#/types/common';
|
||||
|
||||
import { ref } from 'vue';
|
||||
@@ -27,14 +27,15 @@ import {
|
||||
createOrderApi,
|
||||
updateOrderApi,
|
||||
} from '#/api/ecommerce/order';
|
||||
import { getAllOrderStatusListApi } from '#/api/ecommerce/order-status';
|
||||
import type { OrderStatusVO } from '#/api/ecommerce/order-status/types';
|
||||
import { ORDER_STATUS_OPTIONS } from '#/api/ecommerce/order/types/types.enum';
|
||||
import { getProductPageApi } from '#/api/ecommerce/product';
|
||||
import { getProductSkuPageApi } from '#/api/ecommerce/product-sku';
|
||||
import { getShopPageApi } from '#/api/ecommerce/shop';
|
||||
import {
|
||||
getFirstOrderItem,
|
||||
getOrderPayAmount,
|
||||
getOrderReceivedAmount,
|
||||
getOrderServiceFee,
|
||||
} from '#/utils/order-display';
|
||||
|
||||
const emit = defineEmits<{
|
||||
@@ -68,6 +69,8 @@ const formData = ref<
|
||||
platformOrderNo: '',
|
||||
status: undefined as string | undefined,
|
||||
payAmount: 0,
|
||||
serviceFee: 0,
|
||||
receivedAmount: undefined,
|
||||
orderTime: dayjs().format('YYYY-MM-DD HH:mm:ss'),
|
||||
productId: undefined,
|
||||
productSkuId: undefined,
|
||||
@@ -84,7 +87,15 @@ const formData = ref<
|
||||
|
||||
// 下拉选项数据
|
||||
const shopOptions = ref<{ label: string; value: number }[]>([]);
|
||||
const orderStatusOptions = ref<{ label: string; value: string }[]>([]);
|
||||
const shopLoading = ref(false);
|
||||
const shopSearchKeyword = ref('');
|
||||
const shopPage = ref(1);
|
||||
const shopPageSize = 20;
|
||||
const shopTotal = ref(0);
|
||||
const shopLoaded = ref(false);
|
||||
let shopSearchTimer: null | ReturnType<typeof setTimeout> = null;
|
||||
/** 订单状态为后端软约定枚举,前端静态字典,不请求状态表 */
|
||||
const orderStatusOptions = ORDER_STATUS_OPTIONS;
|
||||
|
||||
// 商品选项数据(支持分页)
|
||||
const productOptions = ref<
|
||||
@@ -120,9 +131,6 @@ const rules = {
|
||||
orderTime: [{ required: true, message: '请选择下单时间', trigger: 'change' }],
|
||||
productId: [{ required: true, message: '请选择商品', trigger: 'change' }],
|
||||
productSkuId: [{ required: true, message: '请选择商品 SKU', trigger: 'change' }],
|
||||
linkProductName: [
|
||||
{ required: true, message: '请输入链接商品名称', trigger: 'blur' },
|
||||
],
|
||||
quantity: [{ required: true, message: '请输入数量', trigger: 'blur' }],
|
||||
unitPrice: [{ required: true, message: '请输入销售单价', trigger: 'blur' }],
|
||||
productCost: [{ required: true, message: '请输入商品成本', trigger: 'blur' }],
|
||||
@@ -131,37 +139,67 @@ const rules = {
|
||||
// 表单引用
|
||||
const formRef = ref();
|
||||
|
||||
// 获取店铺选项
|
||||
async function fetchShopOptions() {
|
||||
// 获取店铺选项(分页 + 搜索)
|
||||
async function fetchShopOptions(page = 1, append = false) {
|
||||
if (shopLoading.value) return;
|
||||
shopLoading.value = true;
|
||||
try {
|
||||
const params: any = {
|
||||
page: 1,
|
||||
pageSize: 1000,
|
||||
filters: {},
|
||||
const params: PageQueryDTO<ShopDTO.Filters> = {
|
||||
page,
|
||||
pageSize: shopPageSize,
|
||||
filters: shopSearchKeyword.value
|
||||
? { name: shopSearchKeyword.value }
|
||||
: {},
|
||||
};
|
||||
const data = await getShopPageApi(params);
|
||||
shopOptions.value = data.records.map((shop: ShopVO.Info) => ({
|
||||
const mapped = data.records.map((shop: ShopVO.Info) => ({
|
||||
label: shop.name,
|
||||
value: shop.id,
|
||||
}));
|
||||
shopOptions.value = append ? [...shopOptions.value, ...mapped] : mapped;
|
||||
shopTotal.value = data.total;
|
||||
shopPage.value = page;
|
||||
shopLoaded.value = true;
|
||||
} catch (error) {
|
||||
console.error('获取店铺列表失败:', error);
|
||||
} finally {
|
||||
shopLoading.value = false;
|
||||
}
|
||||
}
|
||||
|
||||
// 获取订单状态选项
|
||||
async function fetchOrderStatusOptions() {
|
||||
try {
|
||||
const data = await getAllOrderStatusListApi();
|
||||
orderStatusOptions.value = data.map((status: OrderStatusVO.Meta) => ({
|
||||
label: status.label,
|
||||
value: status.code,
|
||||
}));
|
||||
} catch (error) {
|
||||
console.error('获取订单状态列表失败:', error);
|
||||
function handleShopSearch(value: string) {
|
||||
if (shopSearchTimer) clearTimeout(shopSearchTimer);
|
||||
shopSearchTimer = setTimeout(() => {
|
||||
shopSearchKeyword.value = value;
|
||||
shopPage.value = 1;
|
||||
fetchShopOptions(1, false);
|
||||
}, 300);
|
||||
}
|
||||
|
||||
function handleShopPopupScroll(e: Event) {
|
||||
const target = e.target as HTMLElement;
|
||||
const { scrollTop, scrollHeight, clientHeight } = target;
|
||||
if (scrollHeight - scrollTop - clientHeight < 50) {
|
||||
const hasMore = shopPage.value * shopPageSize < shopTotal.value;
|
||||
if (hasMore && !shopLoading.value) {
|
||||
fetchShopOptions(shopPage.value + 1, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/** 编辑回填:保证当前店铺出现在选项中 */
|
||||
function ensureShopOption(record?: OrderVO.Info) {
|
||||
if (!record?.shopId) return;
|
||||
if (shopOptions.value.some((o) => o.value === record.shopId)) return;
|
||||
shopOptions.value = [
|
||||
{
|
||||
label: record.shopName || record.shop?.name || `店铺#${record.shopId}`,
|
||||
value: record.shopId,
|
||||
},
|
||||
...shopOptions.value,
|
||||
];
|
||||
}
|
||||
|
||||
// 分页加载商品列表
|
||||
async function fetchProducts(page = 1, append = false) {
|
||||
if (productLoading.value) return;
|
||||
@@ -346,9 +384,11 @@ async function open(edit: boolean, record?: OrderVO.Info) {
|
||||
isEdit.value = edit;
|
||||
currentRecord.value = record || null;
|
||||
|
||||
// 加载下拉选项数据
|
||||
await fetchShopOptions();
|
||||
await fetchOrderStatusOptions();
|
||||
// 加载下拉选项数据(状态用静态枚举,无需请求)
|
||||
shopSearchKeyword.value = '';
|
||||
shopLoaded.value = false;
|
||||
await fetchShopOptions(1, false);
|
||||
ensureShopOption(record);
|
||||
|
||||
modalApi.open();
|
||||
|
||||
@@ -362,6 +402,8 @@ async function open(edit: boolean, record?: OrderVO.Info) {
|
||||
platformOrderNo: record.platformOrderNo || '',
|
||||
status: record.status,
|
||||
payAmount: getOrderPayAmount(record),
|
||||
serviceFee: getOrderServiceFee(record),
|
||||
receivedAmount: getOrderReceivedAmount(record),
|
||||
orderTime: record.orderTime
|
||||
? dayjs(record.orderTime).format('YYYY-MM-DD HH:mm:ss')
|
||||
: dayjs().format('YYYY-MM-DD HH:mm:ss'),
|
||||
@@ -383,6 +425,8 @@ async function open(edit: boolean, record?: OrderVO.Info) {
|
||||
platformOrderNo: '',
|
||||
status: undefined,
|
||||
payAmount: 0,
|
||||
serviceFee: 0,
|
||||
receivedAmount: undefined,
|
||||
orderTime: dayjs().format('YYYY-MM-DD HH:mm:ss'),
|
||||
productId: undefined,
|
||||
productSkuId: undefined,
|
||||
@@ -449,11 +493,27 @@ async function handleSubmit() {
|
||||
await formRef.value?.validate();
|
||||
loading.value = true;
|
||||
|
||||
const productOpt = productOptions.value.find(
|
||||
(o) => o.value === formData.value.productId,
|
||||
);
|
||||
const skuOpt = productSkuOptions.value.find(
|
||||
(o) => o.value === formData.value.productSkuId,
|
||||
);
|
||||
const linkProductName =
|
||||
formData.value.linkProductName?.trim() ||
|
||||
productOpt?.product.name ||
|
||||
productOpt?.label ||
|
||||
'未知商品';
|
||||
const linkSkuName =
|
||||
formData.value.linkSkuName?.trim() ||
|
||||
skuOpt?.sku.name ||
|
||||
undefined;
|
||||
|
||||
const itemPayload = {
|
||||
productSkuId: formData.value.productSkuId,
|
||||
skuCode: formData.value.skuCode,
|
||||
linkProductName: formData.value.linkProductName!,
|
||||
linkSkuName: formData.value.linkSkuName,
|
||||
linkProductName,
|
||||
linkSkuName,
|
||||
quantity: formData.value.quantity!,
|
||||
unitPrice: formData.value.unitPrice,
|
||||
productCost: formData.value.productCost,
|
||||
@@ -468,6 +528,8 @@ async function handleSubmit() {
|
||||
platformOrderNo: formData.value.platformOrderNo,
|
||||
status: formData.value.status,
|
||||
payAmount: formData.value.payAmount!,
|
||||
serviceFee: formData.value.serviceFee,
|
||||
receivedAmount: formData.value.receivedAmount,
|
||||
orderTime: formData.value.orderTime!,
|
||||
items: [itemPayload],
|
||||
remark: formData.value.remark,
|
||||
@@ -480,6 +542,8 @@ async function handleSubmit() {
|
||||
platformOrderNo: formData.value.platformOrderNo,
|
||||
status: formData.value.status!,
|
||||
payAmount: formData.value.payAmount!,
|
||||
serviceFee: formData.value.serviceFee,
|
||||
receivedAmount: formData.value.receivedAmount,
|
||||
orderTime: formData.value.orderTime!,
|
||||
items: [itemPayload],
|
||||
remark: formData.value.remark,
|
||||
@@ -517,9 +581,29 @@ defineExpose({
|
||||
<Form.Item label="店铺" name="shopId">
|
||||
<Select
|
||||
v-model:value="formData.shopId"
|
||||
placeholder="请选择店铺"
|
||||
placeholder="请搜索并选择店铺"
|
||||
show-search
|
||||
:filter-option="false"
|
||||
:loading="shopLoading"
|
||||
:options="shopOptions"
|
||||
/>
|
||||
@search="handleShopSearch"
|
||||
@focus="
|
||||
() => {
|
||||
if (!shopLoaded) fetchShopOptions(1, false);
|
||||
}
|
||||
"
|
||||
@popup-scroll="handleShopPopupScroll"
|
||||
>
|
||||
<template #notFoundContent>
|
||||
<div v-if="shopLoading" class="py-4 text-center">
|
||||
<Spin size="small" />
|
||||
<div class="mt-2">加载中...</div>
|
||||
</div>
|
||||
<div v-else class="py-4 text-center text-gray-400">
|
||||
{{ shopSearchKeyword ? '未找到店铺' : '暂无店铺' }}
|
||||
</div>
|
||||
</template>
|
||||
</Select>
|
||||
</Form.Item>
|
||||
|
||||
<Form.Item label="订单状态" name="status">
|
||||
@@ -610,22 +694,6 @@ defineExpose({
|
||||
</Form.Item>
|
||||
</div>
|
||||
|
||||
<div class="grid grid-cols-2 gap-4">
|
||||
<Form.Item label="链接商品名称" name="linkProductName">
|
||||
<Input
|
||||
v-model:value="formData.linkProductName"
|
||||
placeholder="请输入链接商品名称"
|
||||
/>
|
||||
</Form.Item>
|
||||
|
||||
<Form.Item label="链接 SKU 名称" name="linkSkuName">
|
||||
<Input
|
||||
v-model:value="formData.linkSkuName"
|
||||
placeholder="请输入链接 SKU 名称"
|
||||
/>
|
||||
</Form.Item>
|
||||
</div>
|
||||
|
||||
<div class="grid grid-cols-3 gap-4">
|
||||
<Form.Item label="数量" name="quantity">
|
||||
<InputNumber
|
||||
@@ -687,10 +755,28 @@ defineExpose({
|
||||
/>
|
||||
</Form.Item>
|
||||
|
||||
<Form.Item label="实付/商家实收" name="payAmount">
|
||||
<Form.Item label="实付金额" name="payAmount">
|
||||
<InputNumber
|
||||
v-model:value="formData.payAmount"
|
||||
placeholder="请输入实付/商家实收金额"
|
||||
placeholder="请输入买家实付金额"
|
||||
style="width: 100%"
|
||||
:min="0"
|
||||
:precision="2"
|
||||
/>
|
||||
</Form.Item>
|
||||
<Form.Item label="服务费" name="serviceFee">
|
||||
<InputNumber
|
||||
v-model:value="formData.serviceFee"
|
||||
placeholder="平台服务费(可选)"
|
||||
style="width: 100%"
|
||||
:min="0"
|
||||
:precision="2"
|
||||
/>
|
||||
</Form.Item>
|
||||
<Form.Item label="商家实收" name="receivedAmount">
|
||||
<InputNumber
|
||||
v-model:value="formData.receivedAmount"
|
||||
placeholder="不填则按 实付-服务费+平台优惠"
|
||||
style="width: 100%"
|
||||
:min="0"
|
||||
:precision="2"
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
<script lang="ts" setup>
|
||||
import type { VxeGridProps } from '#/adapter/vxe-table';
|
||||
import type { OrderDTO, OrderVO } from '#/api/ecommerce/order';
|
||||
import type { OrderStatusVO } from '#/api/ecommerce/order-status/types';
|
||||
import { ORDER_STATUS_OPTIONS } from '#/api/ecommerce/order/types/types.enum';
|
||||
import type { ProductDTO, ProductVO } from '#/api/ecommerce/product/types';
|
||||
import type { ShopDTO, ShopVO } from '#/api/ecommerce/shop/types';
|
||||
import type { PageQueryDTO } from '#/types/common';
|
||||
@@ -17,9 +17,9 @@ import dayjs from 'dayjs';
|
||||
|
||||
import {
|
||||
Button,
|
||||
Image,
|
||||
message,
|
||||
Popconfirm,
|
||||
Popover,
|
||||
Space,
|
||||
Tag,
|
||||
} from 'ant-design-vue';
|
||||
@@ -30,44 +30,38 @@ import {
|
||||
deleteOrderApi,
|
||||
getOrderPageApi,
|
||||
} from '#/api/ecommerce/order';
|
||||
import { getAllOrderStatusListApi } from '#/api/ecommerce/order-status';
|
||||
import { getProductPageApi } from '#/api/ecommerce/product';
|
||||
import { getPlatformListApi } from '#/api/ecommerce/platform';
|
||||
import { getShopPageApi } from '#/api/ecommerce/shop';
|
||||
|
||||
import PlatformTag from '#/components/platform/PlatformTag.vue';
|
||||
import {
|
||||
getFirstOrderItem,
|
||||
getOrderOtherCost,
|
||||
getOrderPayAmount,
|
||||
getOrderProduct,
|
||||
getOrderProductCost,
|
||||
getOrderProductSku,
|
||||
getOrderQuantity,
|
||||
getOrderShippingCost,
|
||||
getOrderReceivedAmount,
|
||||
} from '#/utils/order-display';
|
||||
|
||||
import OrderDetailDrawer from './components/OrderDetailDrawer.vue';
|
||||
import OrderFormModal from './components/OrderFormModal.vue';
|
||||
|
||||
defineOptions({ name: 'OrderManagement' });
|
||||
// 创建图标组件
|
||||
|
||||
const PlusIcon = createIconifyIcon('lucide:plus');
|
||||
const router = useRouter();
|
||||
|
||||
function goToShopDetail(shopId: number) {
|
||||
router.push(`/ecom/shop/overview/${shopId}`);
|
||||
}
|
||||
const SOURCE_LABEL: Record<string, string> = {
|
||||
import: '导入',
|
||||
sync: '同步',
|
||||
manual: '手动',
|
||||
};
|
||||
|
||||
function goToProductDetail(productId: number) {
|
||||
router.push(`/ecom/product/overview/${productId}`);
|
||||
}
|
||||
|
||||
// 响应式数据
|
||||
const loading = ref(false);
|
||||
const batchDeleteLoading = ref(false);
|
||||
/** vxe 勾选不触发 Vue 依赖,须用事件同步,勿用 computed 读 getCheckboxRecords */
|
||||
const hasSelected = ref(false);
|
||||
const orderFormModalRef = ref();
|
||||
const orderFormModalRef = ref<InstanceType<typeof OrderFormModal>>();
|
||||
const detailDrawerRef = ref<InstanceType<typeof OrderDetailDrawer>>();
|
||||
|
||||
// 店铺分页数据
|
||||
const shopOptions = ref<{ label: string; value: number }[]>([]);
|
||||
const shopPage = ref(1);
|
||||
const shopPageSize = 20;
|
||||
@@ -77,11 +71,8 @@ const shopSearchKeyword = ref('');
|
||||
const shopLoaded = ref(false);
|
||||
let shopSearchTimer: null | ReturnType<typeof setTimeout> = null;
|
||||
|
||||
// 订单状态选项
|
||||
const orderStatusOptions = ref<{ label: string; value: string }[]>([]);
|
||||
const orderStatusLoaded = ref(false);
|
||||
const orderStatusOptions = ORDER_STATUS_OPTIONS;
|
||||
|
||||
// 商品分页数据
|
||||
const productOptions = ref<{ label: string; value: number }[]>([]);
|
||||
const productPage = ref(1);
|
||||
const productPageSize = 20;
|
||||
@@ -109,16 +100,53 @@ function buildDefaultOrderTimeRange() {
|
||||
|
||||
const defaultOrderTime = buildDefaultOrderTimeRange();
|
||||
|
||||
// 搜索表单(默认近 30 天,避免无时间范围扫全表)
|
||||
const searchForm = ref({
|
||||
platformOrderNo: '',
|
||||
shopId: undefined as number | undefined,
|
||||
platformCode: undefined as string | undefined,
|
||||
status: undefined as string | undefined,
|
||||
startOrderTime: defaultOrderTime.start as string | undefined,
|
||||
endOrderTime: defaultOrderTime.end as string | undefined,
|
||||
productId: undefined as number | undefined,
|
||||
});
|
||||
|
||||
const platformOptions = ref<{ label: string; value: string }[]>([]);
|
||||
const platformLoaded = ref(false);
|
||||
|
||||
const currentSort = ref<null | { field: string; order: 'asc' | 'desc' }>(null);
|
||||
|
||||
function money(v?: null | number) {
|
||||
if (v == null || Number.isNaN(Number(v))) return '-';
|
||||
return `¥${Number(v).toFixed(2)}`;
|
||||
}
|
||||
|
||||
function sourceText(source?: string) {
|
||||
if (!source) return '-';
|
||||
return SOURCE_LABEL[source] ?? source;
|
||||
}
|
||||
|
||||
function regionText(row: OrderVO.Info) {
|
||||
return [row.province, row.city, row.town].filter(Boolean).join(' / ') || '-';
|
||||
}
|
||||
|
||||
function goodsTitle(row: OrderVO.Info) {
|
||||
return (
|
||||
getOrderProduct(row)?.name ||
|
||||
getFirstOrderItem(row)?.linkProductName ||
|
||||
row.firstLinkProductName ||
|
||||
'-'
|
||||
);
|
||||
}
|
||||
|
||||
function goodsSpec(row: OrderVO.Info) {
|
||||
const item = getFirstOrderItem(row);
|
||||
return item?.productSku?.name || item?.linkSkuName || '';
|
||||
}
|
||||
|
||||
function goodsImg(row: OrderVO.Info) {
|
||||
return getFirstOrderItem(row)?.goodsImg;
|
||||
}
|
||||
|
||||
function ensureOrderTimeFilters(): boolean {
|
||||
if (!searchForm.value.startOrderTime || !searchForm.value.endOrderTime) {
|
||||
const d = buildDefaultOrderTimeRange();
|
||||
@@ -142,10 +170,6 @@ function ensureOrderTimeFilters(): boolean {
|
||||
return true;
|
||||
}
|
||||
|
||||
// 当前排序状态
|
||||
const currentSort = ref<null | { field: string; order: 'asc' | 'desc' }>(null);
|
||||
|
||||
// 加载店铺列表(支持分页)
|
||||
async function fetchShops(page = 1, append = false) {
|
||||
if (shopLoading.value) return;
|
||||
shopLoading.value = true;
|
||||
@@ -156,18 +180,11 @@ async function fetchShops(page = 1, append = false) {
|
||||
filters: shopSearchKeyword.value ? { name: shopSearchKeyword.value } : {},
|
||||
};
|
||||
const data = await getShopPageApi(params);
|
||||
shopOptions.value = append
|
||||
? [
|
||||
...shopOptions.value,
|
||||
...data.records.map((shop: ShopVO.Info) => ({
|
||||
label: shop.name,
|
||||
value: shop.id,
|
||||
})),
|
||||
]
|
||||
: data.records.map((shop: ShopVO.Info) => ({
|
||||
label: shop.name,
|
||||
value: shop.id,
|
||||
}));
|
||||
const mapped = data.records.map((shop: ShopVO.Info) => ({
|
||||
label: shop.name,
|
||||
value: shop.id,
|
||||
}));
|
||||
shopOptions.value = append ? [...shopOptions.value, ...mapped] : mapped;
|
||||
shopTotal.value = data.total;
|
||||
shopPage.value = page;
|
||||
shopLoaded.value = true;
|
||||
@@ -178,7 +195,6 @@ async function fetchShops(page = 1, append = false) {
|
||||
}
|
||||
}
|
||||
|
||||
// 搜索店铺(防抖)
|
||||
function handleShopSearch(value: string) {
|
||||
if (shopSearchTimer) clearTimeout(shopSearchTimer);
|
||||
shopSearchTimer = setTimeout(() => {
|
||||
@@ -188,11 +204,9 @@ function handleShopSearch(value: string) {
|
||||
}, 300);
|
||||
}
|
||||
|
||||
// 滚动加载更多店铺
|
||||
function handleShopPopupScroll(e: Event) {
|
||||
const target = e.target as HTMLElement;
|
||||
const { scrollTop, scrollHeight, clientHeight } = target;
|
||||
// 滚动到底部附近时加载更多
|
||||
if (scrollHeight - scrollTop - clientHeight < 50) {
|
||||
const hasMore = shopPage.value * shopPageSize < shopTotal.value;
|
||||
if (hasMore && !shopLoading.value) {
|
||||
@@ -201,7 +215,6 @@ function handleShopPopupScroll(e: Event) {
|
||||
}
|
||||
}
|
||||
|
||||
// 加载商品列表(支持分页)
|
||||
async function fetchProducts(page = 1, append = false) {
|
||||
if (productLoading.value) return;
|
||||
productLoading.value = true;
|
||||
@@ -209,21 +222,18 @@ async function fetchProducts(page = 1, append = false) {
|
||||
const params: PageQueryDTO<ProductDTO.Filters> = {
|
||||
page,
|
||||
pageSize: productPageSize,
|
||||
filters: productSearchKeyword.value ? { name: productSearchKeyword.value } : {},
|
||||
filters: productSearchKeyword.value
|
||||
? { name: productSearchKeyword.value }
|
||||
: {},
|
||||
};
|
||||
const data = await getProductPageApi(params);
|
||||
const mapped = data.records.map((product: ProductVO.Info) => ({
|
||||
label: product.name,
|
||||
value: product.id,
|
||||
}));
|
||||
productOptions.value = append
|
||||
? [
|
||||
...productOptions.value,
|
||||
...data.records.map((product: ProductVO.Info) => ({
|
||||
label: product.name,
|
||||
value: product.id,
|
||||
})),
|
||||
]
|
||||
: data.records.map((product: ProductVO.Info) => ({
|
||||
label: product.name,
|
||||
value: product.id,
|
||||
}));
|
||||
? [...productOptions.value, ...mapped]
|
||||
: mapped;
|
||||
productTotal.value = data.total;
|
||||
productPage.value = page;
|
||||
productLoaded.value = true;
|
||||
@@ -234,7 +244,6 @@ async function fetchProducts(page = 1, append = false) {
|
||||
}
|
||||
}
|
||||
|
||||
// 搜索商品(防抖)
|
||||
function handleProductSearch(value: string) {
|
||||
if (productSearchTimer) clearTimeout(productSearchTimer);
|
||||
productSearchTimer = setTimeout(() => {
|
||||
@@ -244,11 +253,9 @@ function handleProductSearch(value: string) {
|
||||
}, 300);
|
||||
}
|
||||
|
||||
// 滚动加载更多商品
|
||||
function handleProductPopupScroll(e: Event) {
|
||||
const target = e.target as HTMLElement;
|
||||
const { scrollTop, scrollHeight, clientHeight } = target;
|
||||
// 滚动到底部附近时加载更多
|
||||
if (scrollHeight - scrollTop - clientHeight < 50) {
|
||||
const hasMore = productPage.value * productPageSize < productTotal.value;
|
||||
if (hasMore && !productLoading.value) {
|
||||
@@ -257,18 +264,26 @@ function handleProductPopupScroll(e: Event) {
|
||||
}
|
||||
}
|
||||
|
||||
// VbenVxeGrid 表格配置
|
||||
const gridOptions: VxeGridProps<any> = {
|
||||
async function fetchPlatformOptions() {
|
||||
try {
|
||||
const data = await getPlatformListApi();
|
||||
platformOptions.value = (data ?? []).map((p) => ({
|
||||
label: p.label,
|
||||
value: p.code,
|
||||
}));
|
||||
platformLoaded.value = true;
|
||||
} catch (error) {
|
||||
console.error('获取平台字典失败:', error);
|
||||
}
|
||||
}
|
||||
|
||||
const gridOptions: VxeGridProps<OrderVO.Info> = {
|
||||
checkboxConfig: {
|
||||
highlight: true,
|
||||
reserve: false,
|
||||
},
|
||||
columns: [
|
||||
{
|
||||
type: 'seq' as const,
|
||||
minWidth: 'auto',
|
||||
title: '序号',
|
||||
},
|
||||
{ type: 'seq' as const, width: 56, title: '序号' },
|
||||
{
|
||||
type: 'checkbox' as const,
|
||||
width: 48,
|
||||
@@ -277,79 +292,68 @@ const gridOptions: VxeGridProps<any> = {
|
||||
{
|
||||
field: 'platformOrderNo',
|
||||
title: '平台订单号',
|
||||
minWidth: 'auto',
|
||||
minWidth: 180,
|
||||
showOverflow: 'tooltip' as const,
|
||||
sortable: true,
|
||||
},
|
||||
{
|
||||
title: '平台',
|
||||
width: 100,
|
||||
slots: { default: 'platform' },
|
||||
},
|
||||
{
|
||||
field: 'shopName',
|
||||
title: '店铺名称',
|
||||
minWidth: 140,
|
||||
showOverflow: false,
|
||||
title: '店铺',
|
||||
minWidth: 120,
|
||||
showOverflow: 'tooltip' as const,
|
||||
sortable: true,
|
||||
slots: { default: 'shopName' },
|
||||
},
|
||||
{
|
||||
title: '商品信息',
|
||||
minWidth: 160,
|
||||
title: '商品',
|
||||
minWidth: 240,
|
||||
showOverflow: false,
|
||||
slots: { default: 'productInfo' },
|
||||
},
|
||||
{
|
||||
title: 'SKU 信息',
|
||||
minWidth: 160,
|
||||
showOverflow: false,
|
||||
slots: { default: 'skuInfo' },
|
||||
},
|
||||
{
|
||||
field: 'quantity',
|
||||
title: '数量',
|
||||
minWidth: 'auto',
|
||||
sortable: true,
|
||||
slots: { default: 'quantity' },
|
||||
slots: { default: 'goods' },
|
||||
},
|
||||
{
|
||||
field: 'payAmount',
|
||||
title: '实付金额',
|
||||
minWidth: 'auto',
|
||||
title: '实付',
|
||||
width: 100,
|
||||
sortable: true,
|
||||
slots: { default: 'payAmount' },
|
||||
},
|
||||
{
|
||||
field: 'productCost',
|
||||
title: '商品成本',
|
||||
minWidth: 'auto',
|
||||
field: 'receivedAmount',
|
||||
title: '商家实收',
|
||||
width: 110,
|
||||
sortable: true,
|
||||
slots: { default: 'productCost' },
|
||||
},
|
||||
{
|
||||
field: 'shippingCost',
|
||||
title: '运费',
|
||||
minWidth: 'auto',
|
||||
sortable: true,
|
||||
slots: { default: 'shippingCost' },
|
||||
},
|
||||
{
|
||||
field: 'otherCost',
|
||||
title: '其他成本',
|
||||
minWidth: 'auto',
|
||||
sortable: true,
|
||||
slots: { default: 'otherCost' },
|
||||
slots: { default: 'receivedAmount' },
|
||||
},
|
||||
{
|
||||
title: '订单状态',
|
||||
minWidth: 'auto',
|
||||
width: 110,
|
||||
slots: { default: 'orderStatus' },
|
||||
},
|
||||
{
|
||||
title: '来源',
|
||||
width: 80,
|
||||
slots: { default: 'source' },
|
||||
},
|
||||
{
|
||||
field: 'orderTime',
|
||||
title: '下单时间',
|
||||
minWidth: 'auto',
|
||||
minWidth: 160,
|
||||
sortable: true,
|
||||
},
|
||||
{
|
||||
title: '收件地区',
|
||||
minWidth: 140,
|
||||
showOverflow: 'tooltip' as const,
|
||||
slots: { default: 'region' },
|
||||
},
|
||||
{
|
||||
title: '操作',
|
||||
minWidth: 'auto',
|
||||
width: 180,
|
||||
fixed: 'right' as const,
|
||||
slots: { default: 'action' },
|
||||
},
|
||||
@@ -357,7 +361,7 @@ const gridOptions: VxeGridProps<any> = {
|
||||
height: 'auto',
|
||||
border: true,
|
||||
stripe: true,
|
||||
rowConfig: { isHover: true },
|
||||
rowConfig: { isHover: true, height: 72 },
|
||||
showOverflow: true,
|
||||
size: 'small',
|
||||
sortConfig: {
|
||||
@@ -395,7 +399,6 @@ const gridOptions: VxeGridProps<any> = {
|
||||
| 'Total'
|
||||
)[],
|
||||
},
|
||||
// 配置远程加载
|
||||
proxyConfig: {
|
||||
ajax: {
|
||||
query: async ({ page, form }) => {
|
||||
@@ -404,15 +407,15 @@ const gridOptions: VxeGridProps<any> = {
|
||||
return { items: [], total: 0 };
|
||||
}
|
||||
loading.value = true;
|
||||
// 从表单获取搜索参数
|
||||
const searchParams = form || {};
|
||||
// 合并表单值和本地状态
|
||||
const filters = {
|
||||
platformOrderNo:
|
||||
searchParams.platformOrderNo ||
|
||||
searchForm.value.platformOrderNo ||
|
||||
undefined,
|
||||
shopId: searchParams.shopId ?? searchForm.value.shopId,
|
||||
platformCode:
|
||||
searchParams.platformCode ?? searchForm.value.platformCode,
|
||||
status: searchParams.status ?? searchForm.value.status,
|
||||
startOrderTime: searchForm.value.startOrderTime,
|
||||
endOrderTime: searchForm.value.endOrderTime,
|
||||
@@ -423,7 +426,6 @@ const gridOptions: VxeGridProps<any> = {
|
||||
pageSize: page.pageSize,
|
||||
filters,
|
||||
};
|
||||
// 处理排序参数
|
||||
if (currentSort.value) {
|
||||
params.sorts = [
|
||||
{
|
||||
@@ -440,10 +442,7 @@ const gridOptions: VxeGridProps<any> = {
|
||||
} catch (error) {
|
||||
console.error('获取订单列表失败:', error);
|
||||
message.error('获取订单列表失败');
|
||||
return {
|
||||
items: [],
|
||||
total: 0,
|
||||
};
|
||||
return { items: [], total: 0 };
|
||||
} finally {
|
||||
loading.value = false;
|
||||
}
|
||||
@@ -452,7 +451,6 @@ const gridOptions: VxeGridProps<any> = {
|
||||
},
|
||||
};
|
||||
|
||||
// 搜索表单配置
|
||||
const gridReloadRef = ref<(() => void) | null>(null);
|
||||
const formOptions = computed(() => ({
|
||||
schema: [
|
||||
@@ -468,6 +466,27 @@ const formOptions = computed(() => ({
|
||||
fieldName: 'platformOrderNo',
|
||||
label: '平台订单号',
|
||||
},
|
||||
{
|
||||
component: 'Select',
|
||||
componentProps: {
|
||||
placeholder: '全部平台',
|
||||
options: platformOptions,
|
||||
allowClear: true,
|
||||
showSearch: true,
|
||||
optionFilterProp: 'label',
|
||||
onFocus: () => {
|
||||
if (!platformLoaded.value) {
|
||||
fetchPlatformOptions();
|
||||
}
|
||||
},
|
||||
onChange: (val: string | undefined) => {
|
||||
searchForm.value.platformCode = val;
|
||||
gridReloadRef.value?.();
|
||||
},
|
||||
},
|
||||
fieldName: 'platformCode',
|
||||
label: '平台',
|
||||
},
|
||||
{
|
||||
component: 'Select',
|
||||
componentProps: {
|
||||
@@ -524,11 +543,6 @@ const formOptions = computed(() => ({
|
||||
placeholder: '请选择状态',
|
||||
options: orderStatusOptions,
|
||||
allowClear: true,
|
||||
onFocus: () => {
|
||||
if (!orderStatusLoaded.value) {
|
||||
fetchOrderStatusOptions();
|
||||
}
|
||||
},
|
||||
onChange: (val: any) => {
|
||||
searchForm.value.status = val;
|
||||
gridReloadRef.value?.();
|
||||
@@ -575,12 +589,9 @@ const formOptions = computed(() => ({
|
||||
},
|
||||
}));
|
||||
|
||||
// 刷新表格数据
|
||||
function refreshTable() {
|
||||
hasSelected.value = false;
|
||||
if (gridApi) {
|
||||
gridApi.reload();
|
||||
}
|
||||
gridApi.reload();
|
||||
}
|
||||
|
||||
function handleSortChange({
|
||||
@@ -594,21 +605,6 @@ function handleSortChange({
|
||||
gridReloadRef.value?.();
|
||||
}
|
||||
|
||||
// 获取订单状态选项
|
||||
async function fetchOrderStatusOptions() {
|
||||
try {
|
||||
const data = await getAllOrderStatusListApi();
|
||||
orderStatusOptions.value = data.map((status: OrderStatusVO.Meta) => ({
|
||||
label: status.label,
|
||||
value: status.code,
|
||||
}));
|
||||
orderStatusLoaded.value = true;
|
||||
} catch (error) {
|
||||
console.error('获取订单状态列表失败:', error);
|
||||
}
|
||||
}
|
||||
|
||||
// 创建 VbenVxeGrid 实例
|
||||
const [Grid, gridApi] = useVbenVxeGrid({
|
||||
gridOptions,
|
||||
formOptions: formOptions.value,
|
||||
@@ -629,17 +625,22 @@ const [Grid, gridApi] = useVbenVxeGrid({
|
||||
});
|
||||
gridReloadRef.value = () => gridApi.reload();
|
||||
|
||||
// 处理添加订单
|
||||
function goToShopDetail(shopId: number) {
|
||||
router.push(`/ecom/shop/overview/${shopId}`);
|
||||
}
|
||||
|
||||
function openDetail(row: OrderVO.Info) {
|
||||
detailDrawerRef.value?.open(row.id);
|
||||
}
|
||||
|
||||
function handleAdd() {
|
||||
orderFormModalRef.value?.open(false);
|
||||
}
|
||||
|
||||
// 处理编辑订单
|
||||
function handleEdit(record: OrderVO.Info) {
|
||||
orderFormModalRef.value?.open(true, record);
|
||||
}
|
||||
|
||||
// 处理删除订单
|
||||
async function handleDelete(record: OrderVO.Info) {
|
||||
try {
|
||||
await deleteOrderApi(record.id);
|
||||
@@ -680,22 +681,23 @@ async function handleBatchDelete() {
|
||||
}
|
||||
}
|
||||
|
||||
// 处理模态框成功
|
||||
function handleModalSuccess() {
|
||||
refreshTable();
|
||||
}
|
||||
|
||||
// 初始化:保证表单与 searchForm 时间一致
|
||||
onMounted(async () => {
|
||||
ensureOrderTimeFilters();
|
||||
await fetchPlatformOptions();
|
||||
});
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<Page auto-content-height>
|
||||
<!-- VbenVxeGrid 表格 -->
|
||||
<Grid :loading="loading" @sort-change="handleSortChange">
|
||||
<!-- 工具栏工具 -->
|
||||
<Grid
|
||||
class="order-grid"
|
||||
:loading="loading"
|
||||
@sort-change="handleSortChange"
|
||||
>
|
||||
<template #toolbar-tools>
|
||||
<Space>
|
||||
<Button type="primary" @click="handleAdd">
|
||||
@@ -710,153 +712,128 @@ onMounted(async () => {
|
||||
:disabled="!hasSelected"
|
||||
@confirm="handleBatchDelete"
|
||||
>
|
||||
<Button danger :disabled="!hasSelected" :loading="batchDeleteLoading">
|
||||
<Button
|
||||
danger
|
||||
:disabled="!hasSelected"
|
||||
:loading="batchDeleteLoading"
|
||||
>
|
||||
批量删除
|
||||
</Button>
|
||||
</Popconfirm>
|
||||
</Space>
|
||||
</template>
|
||||
|
||||
<!-- 店铺名称列 -->
|
||||
<template #shopName="{ row }: { row: any }">
|
||||
<template #platform="{ row }: { row: OrderVO.Info }">
|
||||
<PlatformTag :code="row.platformCode" :label="row.platformLabel" />
|
||||
</template>
|
||||
|
||||
<template #shopName="{ row }: { row: OrderVO.Info }">
|
||||
<a
|
||||
style="color: #1890ff; cursor: pointer"
|
||||
@click="goToShopDetail(row.shopId)"
|
||||
>
|
||||
{{ row.shopName }}
|
||||
{{ row.shopName || `店铺#${row.shopId}` }}
|
||||
</a>
|
||||
</template>
|
||||
|
||||
<!-- 商品信息列(首行明细 / 列表汇总) -->
|
||||
<template #productInfo="{ row }: { row: OrderVO.Info }">
|
||||
<Popover
|
||||
v-if="getOrderProduct(row)?.name || row.firstLinkProductName"
|
||||
:title="undefined"
|
||||
trigger="hover"
|
||||
>
|
||||
<template #content>
|
||||
<div>
|
||||
商品名称:{{
|
||||
getOrderProduct(row)?.name || row.firstLinkProductName
|
||||
}}
|
||||
<template #goods="{ row }: { row: OrderVO.Info }">
|
||||
<div class="goods-cell">
|
||||
<Image
|
||||
v-if="goodsImg(row)"
|
||||
:src="goodsImg(row)"
|
||||
:width="40"
|
||||
:height="40"
|
||||
class="goods-img"
|
||||
/>
|
||||
<div class="goods-meta">
|
||||
<div class="goods-name" :title="goodsTitle(row)">
|
||||
{{ goodsTitle(row) }}
|
||||
</div>
|
||||
<div>
|
||||
商品编码:{{ getOrderProduct(row)?.productCode || '-' }}
|
||||
<div class="goods-spec">
|
||||
{{ goodsSpec(row) }}
|
||||
<span v-if="(row.itemCount ?? 0) > 1">
|
||||
等 {{ row.itemCount }} 件
|
||||
</span>
|
||||
</div>
|
||||
<div v-if="(row.itemCount ?? 0) > 1">
|
||||
共 {{ row.itemCount }} 行明细
|
||||
</div>
|
||||
</template>
|
||||
<a
|
||||
v-if="getOrderProduct(row)?.id"
|
||||
style="color: #1890ff; cursor: pointer"
|
||||
@click.stop="goToProductDetail(getOrderProduct(row)!.id)"
|
||||
>
|
||||
{{ getOrderProduct(row)!.name }}
|
||||
</a>
|
||||
<span v-else style="color: #1890ff">
|
||||
{{
|
||||
getOrderProduct(row)?.name ||
|
||||
getFirstOrderItem(row)?.linkProductName ||
|
||||
row.firstLinkProductName ||
|
||||
'-'
|
||||
}}
|
||||
<Tag v-if="(row.itemCount ?? 0) > 1" color="blue" class="ml-1">
|
||||
+{{ (row.itemCount ?? 0) - 1 }}
|
||||
</Tag>
|
||||
</span>
|
||||
</Popover>
|
||||
<span v-else style="color: #999">暂无商品信息</span>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<!-- SKU 信息列 -->
|
||||
<template #skuInfo="{ row }: { row: OrderVO.Info }">
|
||||
<Popover
|
||||
v-if="getOrderProductSku(row)?.name || getFirstOrderItem(row)?.linkSkuName"
|
||||
:title="undefined"
|
||||
trigger="hover"
|
||||
>
|
||||
<template #content>
|
||||
<div>
|
||||
SKU 名称:{{
|
||||
getOrderProductSku(row)?.name ||
|
||||
getFirstOrderItem(row)?.linkSkuName
|
||||
}}
|
||||
</div>
|
||||
<div>
|
||||
SKU 编码:{{
|
||||
getOrderProductSku(row)?.skuCode ||
|
||||
getFirstOrderItem(row)?.skuCode ||
|
||||
'-'
|
||||
}}
|
||||
</div>
|
||||
</template>
|
||||
<span style="cursor: default">
|
||||
{{
|
||||
getOrderProductSku(row)?.name ||
|
||||
getFirstOrderItem(row)?.linkSkuName ||
|
||||
'-'
|
||||
}}
|
||||
</span>
|
||||
</Popover>
|
||||
<span v-else style="color: #999">-</span>
|
||||
</template>
|
||||
|
||||
<!-- 数量列 -->
|
||||
<template #quantity="{ row }: { row: OrderVO.Info }">
|
||||
{{ getOrderQuantity(row) }}
|
||||
</template>
|
||||
|
||||
<!-- 实付金额列 -->
|
||||
<template #payAmount="{ row }: { row: OrderVO.Info }">
|
||||
<span style="color: #52c41a; font-weight: bold">
|
||||
¥{{ getOrderPayAmount(row).toFixed(2) }}
|
||||
</span>
|
||||
{{ money(getOrderPayAmount(row)) }}
|
||||
</template>
|
||||
|
||||
<!-- 商品成本列 -->
|
||||
<template #productCost="{ row }: { row: OrderVO.Info }">
|
||||
<span style="color: #ff7875; font-weight: 500">
|
||||
¥{{ getOrderProductCost(row).toFixed(2) }}
|
||||
</span>
|
||||
<template #receivedAmount="{ row }: { row: OrderVO.Info }">
|
||||
{{ money(getOrderReceivedAmount(row)) }}
|
||||
</template>
|
||||
|
||||
<!-- 运费列 -->
|
||||
<template #shippingCost="{ row }: { row: OrderVO.Info }">
|
||||
<span style="color: #ff7875; font-weight: 500">
|
||||
¥{{ getOrderShippingCost(row).toFixed(2) }}
|
||||
</span>
|
||||
</template>
|
||||
|
||||
<!-- 其他成本列 -->
|
||||
<template #otherCost="{ row }: { row: OrderVO.Info }">
|
||||
<span style="color: #ff7875; font-weight: 500">
|
||||
¥{{ getOrderOtherCost(row).toFixed(2) }}
|
||||
</span>
|
||||
</template>
|
||||
|
||||
<!-- 订单状态列 -->
|
||||
<template #orderStatus="{ row }: { row: any }">
|
||||
<Tag :color="row.statusColor || 'blue'" type="outline">
|
||||
<template #orderStatus="{ row }: { row: OrderVO.Info }">
|
||||
<Tag :color="row.statusColor || 'blue'">
|
||||
{{ row.statusLabel || '未知状态' }}
|
||||
</Tag>
|
||||
</template>
|
||||
|
||||
<!-- 操作列 -->
|
||||
<template #action="{ row }: { row: any }">
|
||||
<template #source="{ row }: { row: OrderVO.Info }">
|
||||
{{ sourceText(row.source) }}
|
||||
</template>
|
||||
|
||||
<template #region="{ row }: { row: OrderVO.Info }">
|
||||
{{ regionText(row) }}
|
||||
</template>
|
||||
|
||||
<template #action="{ row }: { row: OrderVO.Info }">
|
||||
<Space>
|
||||
<Button size="small" @click="handleEdit(row)"> 编辑 </Button>
|
||||
<Button type="link" size="small" @click="openDetail(row)">
|
||||
详情
|
||||
</Button>
|
||||
<Button type="link" size="small" @click="handleEdit(row)">
|
||||
编辑
|
||||
</Button>
|
||||
<Popconfirm
|
||||
title="确定要删除这个订单吗?"
|
||||
@confirm="handleDelete(row)"
|
||||
>
|
||||
<Button size="small" danger> 删除 </Button>
|
||||
<Button type="link" size="small" danger>删除</Button>
|
||||
</Popconfirm>
|
||||
</Space>
|
||||
</template>
|
||||
</Grid>
|
||||
|
||||
<!-- 订单表单模态框 -->
|
||||
<OrderFormModal ref="orderFormModalRef" @success="handleModalSuccess" />
|
||||
<OrderDetailDrawer ref="detailDrawerRef" />
|
||||
</Page>
|
||||
</template>
|
||||
|
||||
<style scoped>
|
||||
.goods-cell {
|
||||
display: flex;
|
||||
gap: 8px;
|
||||
align-items: center;
|
||||
min-height: 48px;
|
||||
}
|
||||
|
||||
.goods-img {
|
||||
flex-shrink: 0;
|
||||
overflow: hidden;
|
||||
border-radius: 4px;
|
||||
}
|
||||
|
||||
.goods-meta {
|
||||
min-width: 0;
|
||||
}
|
||||
|
||||
.goods-name {
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
.goods-spec {
|
||||
color: #8c8c8c;
|
||||
font-size: 12px;
|
||||
}
|
||||
|
||||
:deep(.order-grid .vxe-body--column) {
|
||||
vertical-align: middle;
|
||||
}
|
||||
</style>
|
||||
|
||||
+1
@@ -68,6 +68,7 @@ const itemColumns = [
|
||||
|
||||
const moneyFields = computed(() => [
|
||||
{ label: '实付', value: detail.value?.payAmount },
|
||||
{ label: '服务费', value: detail.value?.serviceFee },
|
||||
{ label: '商品金额', value: detail.value?.goodsAmount },
|
||||
{ label: '折扣', value: detail.value?.discountAmount },
|
||||
{ label: '邮费', value: detail.value?.postage },
|
||||
|
||||
Reference in New Issue
Block a user