mirror of
https://gitee.com/qqtt-ah/ecom-dmb.git
synced 2026-11-25 11:49:20 +08:00
- 删除订单管理表的创建时间列 - 商品信息点击跳转改为商品概览页 Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
760 lines
21 KiB
Vue
760 lines
21 KiB
Vue
<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 type { ProductDTO, ProductVO } from '#/api/ecommerce/product/types';
|
||
import type { ShopDTO, ShopVO } from '#/api/ecommerce/shop/types';
|
||
import type { PageQueryDTO } from '#/types/common';
|
||
|
||
import { computed, onMounted, ref } from 'vue';
|
||
|
||
import { useRouter } from 'vue-router';
|
||
|
||
import { Page } from '@vben/common-ui';
|
||
import { createIconifyIcon } from '@vben/icons';
|
||
|
||
import dayjs from 'dayjs';
|
||
|
||
import {
|
||
Button,
|
||
message,
|
||
Popconfirm,
|
||
Popover,
|
||
Space,
|
||
Tag,
|
||
} from 'ant-design-vue';
|
||
|
||
import { useVbenVxeGrid } from '#/adapter/vxe-table';
|
||
import {
|
||
batchDeleteOrdersApi,
|
||
deleteOrderApi,
|
||
getOrderPageApi,
|
||
} from '#/api/ecommerce/order';
|
||
import { getAllOrderStatusListApi } from '#/api/ecommerce/order-status';
|
||
import { getProductPageApi } from '#/api/ecommerce/product';
|
||
import { getShopPageApi } from '#/api/ecommerce/shop';
|
||
|
||
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}`);
|
||
}
|
||
|
||
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 shopOptions = ref<{ label: string; value: number }[]>([]);
|
||
const shopPage = ref(1);
|
||
const shopPageSize = 20;
|
||
const shopTotal = ref(0);
|
||
const shopLoading = ref(false);
|
||
const shopSearchKeyword = ref('');
|
||
const shopLoaded = ref(false);
|
||
let shopSearchTimer: null | ReturnType<typeof setTimeout> = null;
|
||
|
||
// 订单状态选项
|
||
const orderStatusOptions = ref<{ label: string; value: number }[]>([]);
|
||
const orderStatusLoaded = ref(false);
|
||
|
||
// 商品分页数据
|
||
const productOptions = ref<{ label: string; value: number }[]>([]);
|
||
const productPage = ref(1);
|
||
const productPageSize = 20;
|
||
const productTotal = ref(0);
|
||
const productLoading = ref(false);
|
||
const productSearchKeyword = ref('');
|
||
const productLoaded = ref(false);
|
||
let productSearchTimer: null | ReturnType<typeof setTimeout> = null;
|
||
|
||
// 搜索表单
|
||
const searchForm = ref({
|
||
platformOrderNo: '',
|
||
shopId: undefined as number | undefined,
|
||
statusId: undefined as number | undefined,
|
||
startOrderTime: undefined as string | undefined,
|
||
endOrderTime: undefined as string | undefined,
|
||
productId: undefined as number | undefined,
|
||
});
|
||
|
||
// 当前排序状态
|
||
const currentSort = ref<null | { field: string; order: 'asc' | 'desc' }>(null);
|
||
|
||
// 加载店铺列表(支持分页)
|
||
async function fetchShops(page = 1, append = false) {
|
||
if (shopLoading.value) return;
|
||
shopLoading.value = true;
|
||
try {
|
||
const params: PageQueryDTO<ShopDTO.Filters> = {
|
||
page,
|
||
pageSize: shopPageSize,
|
||
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,
|
||
}));
|
||
shopTotal.value = data.total;
|
||
shopPage.value = page;
|
||
shopLoaded.value = true;
|
||
} catch (error) {
|
||
console.error('获取店铺列表失败:', error);
|
||
} finally {
|
||
shopLoading.value = false;
|
||
}
|
||
}
|
||
|
||
// 搜索店铺(防抖)
|
||
function handleShopSearch(value: string) {
|
||
if (shopSearchTimer) clearTimeout(shopSearchTimer);
|
||
shopSearchTimer = setTimeout(() => {
|
||
shopSearchKeyword.value = value;
|
||
shopPage.value = 1;
|
||
fetchShops(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) {
|
||
fetchShops(shopPage.value + 1, true);
|
||
}
|
||
}
|
||
}
|
||
|
||
// 加载商品列表(支持分页)
|
||
async function fetchProducts(page = 1, append = false) {
|
||
if (productLoading.value) return;
|
||
productLoading.value = true;
|
||
try {
|
||
const params: PageQueryDTO<ProductDTO.Filters> = {
|
||
page,
|
||
pageSize: productPageSize,
|
||
filters: productSearchKeyword.value ? { name: productSearchKeyword.value } : {},
|
||
};
|
||
const data = await getProductPageApi(params);
|
||
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,
|
||
}));
|
||
productTotal.value = data.total;
|
||
productPage.value = page;
|
||
productLoaded.value = true;
|
||
} catch (error) {
|
||
console.error('获取商品列表失败:', error);
|
||
} finally {
|
||
productLoading.value = false;
|
||
}
|
||
}
|
||
|
||
// 搜索商品(防抖)
|
||
function handleProductSearch(value: string) {
|
||
if (productSearchTimer) clearTimeout(productSearchTimer);
|
||
productSearchTimer = setTimeout(() => {
|
||
productSearchKeyword.value = value;
|
||
productPage.value = 1;
|
||
fetchProducts(1, false);
|
||
}, 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) {
|
||
fetchProducts(productPage.value + 1, true);
|
||
}
|
||
}
|
||
}
|
||
|
||
// VbenVxeGrid 表格配置
|
||
const gridOptions: VxeGridProps<any> = {
|
||
checkboxConfig: {
|
||
highlight: true,
|
||
reserve: false,
|
||
},
|
||
columns: [
|
||
{
|
||
type: 'seq' as const,
|
||
minWidth: 'auto',
|
||
title: '序号',
|
||
},
|
||
{
|
||
type: 'checkbox' as const,
|
||
width: 48,
|
||
fixed: 'left' as const,
|
||
},
|
||
{
|
||
field: 'platformOrderNo',
|
||
title: '平台订单号',
|
||
minWidth: 'auto',
|
||
showOverflow: 'tooltip' as const,
|
||
sortable: true,
|
||
},
|
||
{
|
||
field: 'shopName',
|
||
title: '店铺名称',
|
||
minWidth: 140,
|
||
showOverflow: false,
|
||
sortable: true,
|
||
slots: { default: 'shopName' },
|
||
},
|
||
{
|
||
title: '商品信息',
|
||
minWidth: 160,
|
||
showOverflow: false,
|
||
slots: { default: 'productInfo' },
|
||
},
|
||
{
|
||
title: '规格信息',
|
||
minWidth: 160,
|
||
showOverflow: false,
|
||
slots: { default: 'specInfo' },
|
||
},
|
||
{
|
||
field: 'quantity',
|
||
title: '数量',
|
||
minWidth: 'auto',
|
||
sortable: true,
|
||
},
|
||
{
|
||
field: 'receivedAmount',
|
||
title: '实收金额',
|
||
minWidth: 'auto',
|
||
sortable: true,
|
||
slots: { default: 'receivedAmount' },
|
||
},
|
||
{
|
||
field: 'productCost',
|
||
title: '商品成本',
|
||
minWidth: 'auto',
|
||
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' },
|
||
},
|
||
{
|
||
title: '订单状态',
|
||
minWidth: 'auto',
|
||
slots: { default: 'orderStatus' },
|
||
},
|
||
{
|
||
field: 'orderTime',
|
||
title: '下单时间',
|
||
minWidth: 'auto',
|
||
sortable: true,
|
||
},
|
||
{
|
||
title: '操作',
|
||
minWidth: 'auto',
|
||
fixed: 'right' as const,
|
||
slots: { default: 'action' },
|
||
},
|
||
],
|
||
height: 'auto',
|
||
border: true,
|
||
stripe: true,
|
||
rowConfig: { isHover: true },
|
||
showOverflow: true,
|
||
size: 'small',
|
||
sortConfig: {
|
||
remote: true,
|
||
trigger: 'cell',
|
||
multiple: false,
|
||
orders: ['desc', 'asc'],
|
||
},
|
||
toolbarConfig: {
|
||
custom: true,
|
||
refresh: true,
|
||
zoom: true,
|
||
},
|
||
data: [],
|
||
pagerConfig: {
|
||
enabled: true,
|
||
pageSizes: [10, 20, 50, 100],
|
||
layouts: [
|
||
'PrevJump',
|
||
'PrevPage',
|
||
'Number',
|
||
'NextPage',
|
||
'NextJump',
|
||
'Sizes',
|
||
'FullJump',
|
||
'Total',
|
||
] as (
|
||
| 'FullJump'
|
||
| 'NextJump'
|
||
| 'NextPage'
|
||
| 'Number'
|
||
| 'PrevJump'
|
||
| 'PrevPage'
|
||
| 'Sizes'
|
||
| 'Total'
|
||
)[],
|
||
},
|
||
// 配置远程加载
|
||
proxyConfig: {
|
||
ajax: {
|
||
query: async ({ page, form }) => {
|
||
try {
|
||
loading.value = true;
|
||
// 从表单获取搜索参数
|
||
const searchParams = form || {};
|
||
// 合并表单值和本地状态
|
||
const filters = {
|
||
platformOrderNo:
|
||
searchParams.platformOrderNo ||
|
||
searchForm.value.platformOrderNo ||
|
||
undefined,
|
||
shopId: searchParams.shopId ?? searchForm.value.shopId,
|
||
statusId: searchParams.statusId ?? searchForm.value.statusId,
|
||
startOrderTime: searchForm.value.startOrderTime,
|
||
endOrderTime: searchForm.value.endOrderTime,
|
||
productId: searchParams.productId ?? searchForm.value.productId,
|
||
};
|
||
const params: PageQueryDTO<OrderDTO.Filters> = {
|
||
page: page.currentPage,
|
||
pageSize: page.pageSize,
|
||
filters,
|
||
};
|
||
// 处理排序参数
|
||
if (currentSort.value) {
|
||
params.sorts = [
|
||
{
|
||
field: currentSort.value.field,
|
||
order: currentSort.value.order,
|
||
},
|
||
];
|
||
}
|
||
const data = await getOrderPageApi(params);
|
||
return {
|
||
items: data.records,
|
||
total: data.total,
|
||
};
|
||
} catch (error) {
|
||
console.error('获取订单列表失败:', error);
|
||
message.error('获取订单列表失败');
|
||
return {
|
||
items: [],
|
||
total: 0,
|
||
};
|
||
} finally {
|
||
loading.value = false;
|
||
}
|
||
},
|
||
},
|
||
},
|
||
};
|
||
|
||
// 搜索表单配置
|
||
const gridReloadRef = ref<(() => void) | null>(null);
|
||
const formOptions = computed(() => ({
|
||
schema: [
|
||
{
|
||
component: 'Input',
|
||
componentProps: {
|
||
placeholder: '请输入平台订单号(回车搜索)',
|
||
onChange: (e: any) => {
|
||
searchForm.value.platformOrderNo = e.target.value;
|
||
},
|
||
onPressEnter: () => gridReloadRef.value?.(),
|
||
},
|
||
fieldName: 'platformOrderNo',
|
||
label: '平台订单号',
|
||
},
|
||
{
|
||
component: 'Select',
|
||
componentProps: {
|
||
placeholder: '请选择店铺(支持搜索)',
|
||
options: shopOptions,
|
||
allowClear: true,
|
||
showSearch: true,
|
||
filterOption: false,
|
||
onSearch: handleShopSearch,
|
||
onFocus: () => {
|
||
if (!shopLoaded.value) {
|
||
fetchShops(1, false);
|
||
}
|
||
},
|
||
onPopupScroll: handleShopPopupScroll,
|
||
onChange: (val: any) => {
|
||
searchForm.value.shopId = val;
|
||
gridReloadRef.value?.();
|
||
},
|
||
loading: shopLoading,
|
||
dropdownMenuColumnStyle: { maxHeight: '300px', overflow: 'auto' },
|
||
},
|
||
fieldName: 'shopId',
|
||
label: '店铺',
|
||
},
|
||
{
|
||
component: 'Select',
|
||
componentProps: {
|
||
placeholder: '请选择商品(支持搜索)',
|
||
options: productOptions,
|
||
allowClear: true,
|
||
showSearch: true,
|
||
filterOption: false,
|
||
onSearch: handleProductSearch,
|
||
onFocus: () => {
|
||
if (!productLoaded.value) {
|
||
fetchProducts(1, false);
|
||
}
|
||
},
|
||
onPopupScroll: handleProductPopupScroll,
|
||
onChange: (val: any) => {
|
||
searchForm.value.productId = val ?? undefined;
|
||
gridReloadRef.value?.();
|
||
},
|
||
loading: productLoading,
|
||
dropdownMenuColumnStyle: { maxHeight: '300px', overflow: 'auto' },
|
||
},
|
||
fieldName: 'productId',
|
||
label: '商品',
|
||
},
|
||
{
|
||
component: 'Select',
|
||
componentProps: {
|
||
placeholder: '请选择状态',
|
||
options: orderStatusOptions,
|
||
allowClear: true,
|
||
onFocus: () => {
|
||
if (!orderStatusLoaded.value) {
|
||
fetchOrderStatusOptions();
|
||
}
|
||
},
|
||
onChange: (val: any) => {
|
||
searchForm.value.statusId = val;
|
||
gridReloadRef.value?.();
|
||
},
|
||
},
|
||
fieldName: 'statusId',
|
||
label: '订单状态',
|
||
},
|
||
{
|
||
component: 'RangePicker',
|
||
componentProps: {
|
||
placeholder: ['下单开始时间', '下单结束时间'],
|
||
allowClear: true,
|
||
showTime: { format: 'HH:mm:ss' },
|
||
format: 'YYYY-MM-DD HH:mm:ss',
|
||
style: { width: '100%' },
|
||
onChange: (val: any) => {
|
||
searchForm.value.startOrderTime = val && val[0]
|
||
? (val[0] as dayjs.Dayjs).format('YYYY-MM-DD HH:mm:ss')
|
||
: undefined;
|
||
searchForm.value.endOrderTime = val && val[1]
|
||
? (val[1] as dayjs.Dayjs).format('YYYY-MM-DD HH:mm:ss')
|
||
: undefined;
|
||
gridReloadRef.value?.();
|
||
},
|
||
},
|
||
fieldName: 'orderTimeRange',
|
||
label: '下单时间',
|
||
},
|
||
],
|
||
showDefaultActions: true,
|
||
collapsed: true,
|
||
collapsedRows: 2,
|
||
}));
|
||
|
||
// 刷新表格数据
|
||
function refreshTable() {
|
||
hasSelected.value = false;
|
||
if (gridApi) {
|
||
gridApi.reload();
|
||
}
|
||
}
|
||
|
||
function handleSortChange({
|
||
field,
|
||
order,
|
||
}: {
|
||
field?: string;
|
||
order?: 'asc' | 'desc' | null;
|
||
}) {
|
||
currentSort.value = field ? { field, order: order || 'desc' } : null;
|
||
gridReloadRef.value?.();
|
||
}
|
||
|
||
// 获取订单状态选项
|
||
async function fetchOrderStatusOptions() {
|
||
try {
|
||
const data = await getAllOrderStatusListApi();
|
||
orderStatusOptions.value = data.map((status: OrderStatusVO.Info) => ({
|
||
label: status.statusName,
|
||
value: status.id,
|
||
}));
|
||
orderStatusLoaded.value = true;
|
||
} catch (error) {
|
||
console.error('获取订单状态列表失败:', error);
|
||
}
|
||
}
|
||
|
||
// 创建 VbenVxeGrid 实例
|
||
const [Grid, gridApi] = useVbenVxeGrid({
|
||
gridOptions,
|
||
formOptions: formOptions.value,
|
||
showSearchForm: true,
|
||
tableTitle: '订单管理',
|
||
gridEvents: {
|
||
checkboxChange() {
|
||
const vxeTable = (gridApi as any).grid;
|
||
const rows = vxeTable?.getCheckboxRecords?.() ?? [];
|
||
hasSelected.value = rows.length > 0;
|
||
},
|
||
checkboxAll() {
|
||
const vxeTable = (gridApi as any).grid;
|
||
const rows = vxeTable?.getCheckboxRecords?.() ?? [];
|
||
hasSelected.value = rows.length > 0;
|
||
},
|
||
},
|
||
});
|
||
gridReloadRef.value = () => gridApi.reload();
|
||
|
||
// 处理添加订单
|
||
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);
|
||
message.success('删除成功');
|
||
refreshTable();
|
||
} catch (error) {
|
||
console.error('删除订单失败:', error);
|
||
message.error('删除订单失败');
|
||
}
|
||
}
|
||
|
||
async function handleBatchDelete() {
|
||
const vxeTable = (gridApi as any).grid;
|
||
const selectedRows: OrderVO.Info[] = vxeTable?.getCheckboxRecords?.() ?? [];
|
||
if (!selectedRows.length) {
|
||
message.warning('请选择要删除的订单');
|
||
return;
|
||
}
|
||
const orderIds = selectedRows.map((r) => r.id).filter((id) => id != null);
|
||
if (!orderIds.length) {
|
||
message.warning('所选行缺少订单ID');
|
||
return;
|
||
}
|
||
batchDeleteLoading.value = true;
|
||
try {
|
||
await batchDeleteOrdersApi({ orderIds });
|
||
message.success(`已删除 ${orderIds.length} 条订单`);
|
||
vxeTable?.clearCheckboxRow?.();
|
||
hasSelected.value = false;
|
||
await gridApi.reload();
|
||
} catch (error: any) {
|
||
console.error('批量删除订单失败:', error);
|
||
const msg =
|
||
error?.response?.data?.message || error?.message || '批量删除失败';
|
||
message.error(msg);
|
||
} finally {
|
||
batchDeleteLoading.value = false;
|
||
}
|
||
}
|
||
|
||
// 处理模态框成功
|
||
function handleModalSuccess() {
|
||
refreshTable();
|
||
}
|
||
|
||
// 初始化
|
||
onMounted(async () => {
|
||
// 店铺、订单状态、商品选择器改为点击时懒加载,不再预加载
|
||
});
|
||
</script>
|
||
|
||
<template>
|
||
<Page auto-content-height>
|
||
<!-- VbenVxeGrid 表格 -->
|
||
<Grid :loading="loading" @sort-change="handleSortChange">
|
||
<!-- 工具栏工具 -->
|
||
<template #toolbar-tools>
|
||
<Space>
|
||
<Button type="primary" @click="handleAdd">
|
||
<PlusIcon />
|
||
添加订单
|
||
</Button>
|
||
<Popconfirm
|
||
title="确定删除选中的订单吗?删除后不可恢复。"
|
||
ok-text="确定删除"
|
||
cancel-text="取消"
|
||
:ok-button-props="{ danger: true, loading: batchDeleteLoading }"
|
||
:disabled="!hasSelected"
|
||
@confirm="handleBatchDelete"
|
||
>
|
||
<Button danger :disabled="!hasSelected" :loading="batchDeleteLoading">
|
||
批量删除
|
||
</Button>
|
||
</Popconfirm>
|
||
</Space>
|
||
</template>
|
||
|
||
<!-- 店铺名称列 -->
|
||
<template #shopName="{ row }: { row: any }">
|
||
<a
|
||
style="color: #1890ff; cursor: pointer"
|
||
@click="goToShopDetail(row.shopId)"
|
||
>
|
||
{{ row.shopName }}
|
||
</a>
|
||
</template>
|
||
|
||
<!-- 商品信息列 -->
|
||
<template #productInfo="{ row }: { row: any }">
|
||
<Popover
|
||
v-if="row.product?.name"
|
||
:title="undefined"
|
||
trigger="hover"
|
||
>
|
||
<template #content>
|
||
<div>商品名称:{{ row.product.name }}</div>
|
||
<div>商品编码:{{ row.product.productCode || '-' }}</div>
|
||
</template>
|
||
<a
|
||
v-if="row.product?.id"
|
||
style="color: #1890ff; cursor: pointer"
|
||
@click.stop="goToProductDetail(row.product.id)"
|
||
>
|
||
{{ row.product.name }}
|
||
</a>
|
||
<span v-else style="color: #1890ff">{{ row.product.name }}</span>
|
||
</Popover>
|
||
<span v-else style="color: #999">暂无商品信息</span>
|
||
</template>
|
||
|
||
<!-- 规格信息列 -->
|
||
<template #specInfo="{ row }: { row: any }">
|
||
<Popover
|
||
v-if="row.productSpec?.name"
|
||
:title="undefined"
|
||
trigger="hover"
|
||
>
|
||
<template #content>
|
||
<div>规格名称:{{ row.productSpec.name }}</div>
|
||
<div>规格编码:{{ row.productSpec.specCode || '-' }}</div>
|
||
</template>
|
||
<span style="cursor: default">{{ row.productSpec.name }}</span>
|
||
</Popover>
|
||
<span v-else style="color: #999">-</span>
|
||
</template>
|
||
|
||
<!-- 数量列 -->
|
||
<template #quantity="{ row }: { row: any }">
|
||
{{ row.quantity || 0 }}
|
||
</template>
|
||
|
||
<!-- 实收金额列 -->
|
||
<template #receivedAmount="{ row }: { row: any }">
|
||
<span style="color: #52c41a; font-weight: bold">
|
||
¥{{ (row.receivedAmount || 0).toFixed(2) }}
|
||
</span>
|
||
</template>
|
||
|
||
<!-- 商品成本列 -->
|
||
<template #productCost="{ row }: { row: any }">
|
||
<span style="color: #ff7875; font-weight: 500">
|
||
¥{{ (row.productCost || 0).toFixed(2) }}
|
||
</span>
|
||
</template>
|
||
|
||
<!-- 运费列 -->
|
||
<template #shippingCost="{ row }: { row: any }">
|
||
<span style="color: #ff7875; font-weight: 500">
|
||
¥{{ (row.shippingCost || 0).toFixed(2) }}
|
||
</span>
|
||
</template>
|
||
|
||
<!-- 其他成本列 -->
|
||
<template #otherCost="{ row }: { row: any }">
|
||
<span style="color: #ff7875; font-weight: 500">
|
||
¥{{ (row.otherCost || 0).toFixed(2) }}
|
||
</span>
|
||
</template>
|
||
|
||
<!-- 订单状态列 -->
|
||
<template #orderStatus="{ row }: { row: any }">
|
||
<Tag :color="row.orderStatus?.color || 'blue'" type="outline">
|
||
{{ row.statusName || '未知状态' }}
|
||
</Tag>
|
||
</template>
|
||
|
||
<!-- 操作列 -->
|
||
<template #action="{ row }: { row: any }">
|
||
<Space>
|
||
<Button size="small" @click="handleEdit(row)"> 编辑 </Button>
|
||
<Popconfirm
|
||
title="确定要删除这个订单吗?"
|
||
@confirm="handleDelete(row)"
|
||
>
|
||
<Button size="small" danger> 删除 </Button>
|
||
</Popconfirm>
|
||
</Space>
|
||
</template>
|
||
</Grid>
|
||
|
||
<!-- 订单表单模态框 -->
|
||
<OrderFormModal ref="orderFormModalRef" @success="handleModalSuccess" />
|
||
</Page>
|
||
</template>
|