feat(shopOrder): 添加订单商品明细展开功能并优化订单状态显示
- 在订单列表中增加商品明细的展开/收起功能,默认显示2条商品信息 - 支持点击“展开全部 N 件”切换显示全部或折叠商品明细 - 优化订单状态栏支付状态、发货状态、开票状态及操作按钮中的分隔线统一风格 - 将shop/dashboard运行天数改为基于租户创建时间,而非订阅生效时间,保证准确性 - 调整订单列表表格列宽及显示顺序,改善界面布局和信息展示 - 注释和代码格式微调,删除无用的组件显示及注释代码,提升代码整洁度 - 修复了部分变量定义和模板标签排版,完善代码可维护性
This commit is contained in:
@@ -4,3 +4,21 @@
|
||||
- 文件:`src/views/shop/shopOrder/index.vue` 的 `column.key === 'action'` 操作列模板。
|
||||
- 改动:原本操作列按钮只用 `<a-space>` 包裹、无分隔线;现按 `shop/shopGoods` 的写法,在「详情」与各条件块之间、以及块内多个按钮之间加入 `<a-divider type="vertical" />`。
|
||||
- 分隔线放在各 `<template v-if>` 条件块内部,仅当对应操作出现时才渲染,避免多余竖线。
|
||||
|
||||
## 订单列表商品明细展开/收起(方案一已落地)
|
||||
- 文件:`src/views/shop/shopOrder/index.vue`。
|
||||
- 需求:商品明细较多时列表行被撑高,加「展开/收起」。采用方案一(单元格内展开),已确认执行。
|
||||
- 实现:
|
||||
- 新增 `expandedOrderIds: ref<Set<string>>`(用 `String(record.orderId)` 作 key,因 orderId 为 number|undefined)。
|
||||
- 新增 `collapsedGoodsCount = 2`、`isOrderGoodsExpanded(record)`、`toggleOrderGoodsExpanded(record)`。
|
||||
- 改写 `column.key === 'orderGoods'` 模板:默认 `record.orderGoods.slice(0, 2)`,超过 2 件显示「展开全部 N 件」,点击切换,展开后文案变「收起」。
|
||||
- 类型检查:`vue-tsc --noEmit` 仅有的 3 处报错(line 2 `$router`/page-header、line 696/734 未用变量)均为项目既有,与本次改动无关。
|
||||
|
||||
## shop/dashboard 运行天数改为取租户创建时间
|
||||
- 文件:`src/views/shop/dashboard/index.vue`。
|
||||
- 需求:/dashboard 的"运行天数"要改用「租户创建时间」而不是订阅生效时间。
|
||||
- 现状调查:
|
||||
- `cms/dashboard`(站点控制台,标题"系统运行天数")已在提交 894592c 改为 `getTenantInfo().createTime`(租户创建时间),已是目标行为。
|
||||
- `shop/dashboard`(商城后台,标签"运行天数")原用 `currentSubscription.startTime`(订阅生效时间)。
|
||||
- 改动:将 shop/dashboard 的 `runDays` computed 改为取 `tenantStore.company?.createTime`(loadData 已 `tenantStore.fetchTenantInfo()` 写入 company)。同步更新顶部数据来源注释。
|
||||
- 数据源说明:`getTenantInfo()` 返回 `Company`,其 `createTime` 字段即租户创建时间(`src/api/system/company/model/index.ts` line 164);`site.ts` 的 `runDays` getter 仍用 `siteInfo.createTime`(站点创建时间),目前 cms/dashboard 已不依赖它。
|
||||
|
||||
@@ -344,10 +344,10 @@ const { loading: statisticsLoading } = storeToRefs(statisticsStore);
|
||||
// ============================================================
|
||||
// 基本信息:数据来源拆分
|
||||
// - 身份信息(系统名称/版本号/运行状态)来自 app_product (productId=65)
|
||||
// - 时间线(创建时间/到期时间/系统运行天数)来自 app_subscription
|
||||
// · 创建时间 = subscription.startTime(订阅生效时间)
|
||||
// - 时间线(开通时间/到期时间)来自 app_subscription
|
||||
// · 开通时间 = subscription.startTime(订阅生效时间)
|
||||
// · 到期时间 = subscription.expireTime
|
||||
// · 系统运行天数 = 自 subscription.createTime 起累计
|
||||
// - 系统运行天数 = 自租户创建时间起累计(tenantStore.company.createTime)
|
||||
// ============================================================
|
||||
// 当前应用产品(按固定 productId=65 查询)
|
||||
const currentProduct = ref<AppProduct | null>(null);
|
||||
@@ -643,15 +643,13 @@ const onPayModalClose = () => {
|
||||
// 计算属性
|
||||
const now = ref(Date.now());
|
||||
let runDaysTimer: ReturnType<typeof setInterval>;
|
||||
// 系统运行天数:自订阅生效时间起累计
|
||||
// 锚定 currentSubscription.startTime(与"创建时间"行同源,语义统一)。
|
||||
// 注意:若后端续费为新增订阅记录,此处取的是 expireTime 最新的 active 订阅,
|
||||
// startTime 可能是续费生效日,runDays 会从续费日重新计数。
|
||||
// 如需"累计运行天数",应改用最早的 active 订阅 startTime 或后端额外提供字段。
|
||||
// 系统运行天数:自租户创建时间起累计
|
||||
// 锚定 tenantStore.company.createTime(租户建档时间),与后台租户创建时间一致。
|
||||
// 数据来源:loadData 中已调用 tenantStore.fetchTenantInfo() 写入 tenantStore.company。
|
||||
const runDays = computed(() => {
|
||||
const startTime = currentSubscription.value?.startTime;
|
||||
if (!startTime) return 0;
|
||||
return Math.floor((now.value - new Date(startTime).getTime()) / (24 * 60 * 60 * 1000));
|
||||
const createTime = tenantStore.company?.createTime;
|
||||
if (!createTime) return 0;
|
||||
return Math.floor((now.value - new Date(createTime).getTime()) / (24 * 60 * 60 * 1000));
|
||||
});
|
||||
const userCount = computed(() => statisticsStore.userCount);
|
||||
const orderCount = computed(() => statisticsStore.orderCount);
|
||||
|
||||
@@ -14,68 +14,66 @@
|
||||
<!-- <span>批量删除</span>-->
|
||||
<!-- </a-button>-->
|
||||
<a-input-search
|
||||
allow-clear
|
||||
v-model:value="where.orderNo"
|
||||
placeholder="订单编号"
|
||||
style="width: 260px"
|
||||
@search="reload"
|
||||
@pressEnter="reload"
|
||||
allow-clear
|
||||
v-model:value="where.orderNo"
|
||||
placeholder="订单编号"
|
||||
style="width: 240px"
|
||||
@search="reload"
|
||||
@pressEnter="reload"
|
||||
/>
|
||||
<!-- <a-select-->
|
||||
<!-- v-model:value="where.type"-->
|
||||
<!-- style="width: 150px"-->
|
||||
<!-- placeholder="订单类型"-->
|
||||
<!-- @change="search"-->
|
||||
<!-- >-->
|
||||
<!-- <a-select-option value="">全部</a-select-option>-->
|
||||
<!-- <a-select-option :value="1">普通订单</a-select-option>-->
|
||||
<!-- <a-select-option :value="2">秒杀订单</a-select-option>-->
|
||||
<!-- <a-select-option :value="3">拼团订单</a-select-option>-->
|
||||
<!-- </a-select>-->
|
||||
<!-- <a-select-->
|
||||
<!-- v-model:value="where.payStatus"-->
|
||||
<!-- style="width: 150px"-->
|
||||
<!-- placeholder="付款状态"-->
|
||||
<!-- @change="search"-->
|
||||
<!-- >-->
|
||||
<!-- <a-select-option value="">全部</a-select-option>-->
|
||||
<!-- <a-select-option :value="1">已付款</a-select-option>-->
|
||||
<!-- <a-select-option :value="0">未付款</a-select-option>-->
|
||||
<!-- </a-select>-->
|
||||
<!-- <a-select-->
|
||||
<!-- v-model:value="where.type"-->
|
||||
<!-- style="width: 150px"-->
|
||||
<!-- placeholder="订单类型"-->
|
||||
<!-- @change="search"-->
|
||||
<!-- >-->
|
||||
<!-- <a-select-option value="">全部</a-select-option>-->
|
||||
<!-- <a-select-option :value="1">普通订单</a-select-option>-->
|
||||
<!-- <a-select-option :value="2">秒杀订单</a-select-option>-->
|
||||
<!-- <a-select-option :value="3">拼团订单</a-select-option>-->
|
||||
<!-- </a-select>-->
|
||||
<a-select
|
||||
v-model:value="where.orderStatus"
|
||||
style="width: 150px"
|
||||
placeholder="订单状态"
|
||||
@change="search"
|
||||
v-model:value="where.payStatus"
|
||||
style="width: 150px"
|
||||
placeholder="付款状态"
|
||||
@change="search"
|
||||
>
|
||||
<a-select-option value="">全部</a-select-option>
|
||||
<a-select-option :value="1">已完成</a-select-option>
|
||||
<!-- <a-select-option :value="0">未完成</a-select-option>-->
|
||||
<!-- <a-select-option :value="2">未使用</a-select-option>-->
|
||||
<a-select-option :value="3">已取消</a-select-option>
|
||||
<a-select-option :value="4">退款中</a-select-option>
|
||||
<a-select-option :value="5">退款被拒</a-select-option>
|
||||
<a-select-option :value="6">退款成功</a-select-option>
|
||||
<a-select-option :value="1">已付款</a-select-option>
|
||||
<a-select-option :value="0">未付款</a-select-option>
|
||||
</a-select>
|
||||
<!-- <a-select-->
|
||||
<!-- :options="getPayType()"-->
|
||||
<!-- v-model:value="where.payType"-->
|
||||
<!-- style="width: 150px"-->
|
||||
<!-- placeholder="付款方式"-->
|
||||
<!-- @change="search"-->
|
||||
<!-- />-->
|
||||
<!-- <a-select-->
|
||||
<!-- v-model:value="where.orderStatus"-->
|
||||
<!-- style="width: 150px"-->
|
||||
<!-- placeholder="订单状态"-->
|
||||
<!-- @change="search"-->
|
||||
<!-- >-->
|
||||
<!-- <a-select-option value="">全部</a-select-option>-->
|
||||
<!-- <a-select-option :value="1">已完成</a-select-option>-->
|
||||
<!-- <a-select-option :value="3">已取消</a-select-option>-->
|
||||
<!-- <a-select-option :value="4">退款中</a-select-option>-->
|
||||
<!-- <a-select-option :value="5">退款被拒</a-select-option>-->
|
||||
<!-- <a-select-option :value="6">退款成功</a-select-option>-->
|
||||
<!-- </a-select>-->
|
||||
<a-select
|
||||
:options="getPayType()"
|
||||
v-model:value="where.payType"
|
||||
style="width: 150px"
|
||||
placeholder="付款方式"
|
||||
@change="search"
|
||||
/>
|
||||
|
||||
<a-range-picker
|
||||
v-model:value="dateRange"
|
||||
@change="search"
|
||||
value-format="YYYY-MM-DD"
|
||||
v-model:value="dateRange"
|
||||
@change="search"
|
||||
value-format="YYYY-MM-DD"
|
||||
/>
|
||||
<a-input-search
|
||||
allow-clear
|
||||
:placeholder="getSearchPlaceholder()"
|
||||
style="width: 320px"
|
||||
v-model:value="where.keywords"
|
||||
@search="reload"
|
||||
allow-clear
|
||||
:placeholder="getSearchPlaceholder()"
|
||||
style="width: 320px"
|
||||
v-model:value="where.keywords"
|
||||
@search="reload"
|
||||
>
|
||||
<template #addonBefore>
|
||||
<a-select v-model:value="type" style="width: 88px" @change="onType">
|
||||
@@ -102,13 +100,13 @@ import {listShopOrderGoods} from '@/api/shop/shopOrderGoods';
|
||||
import {getPayType} from '@/utils/shop';
|
||||
|
||||
const props = withDefaults(
|
||||
defineProps<{
|
||||
// 选中的订单
|
||||
selection?: ShopOrder[];
|
||||
// 当前列表标签对应的筛选状态(如待发货=1),导出时一并带入
|
||||
statusFilter?: number;
|
||||
}>(),
|
||||
{}
|
||||
defineProps<{
|
||||
// 选中的订单
|
||||
selection?: ShopOrder[];
|
||||
// 当前列表标签对应的筛选状态(如待发货=1),导出时一并带入
|
||||
statusFilter?: number;
|
||||
}>(),
|
||||
{}
|
||||
);
|
||||
|
||||
const emit = defineEmits<{
|
||||
@@ -223,11 +221,11 @@ const getDeliveryStatusLabel = (s?: number) => {
|
||||
const getGoodsSummary = (goods?: any[]) => {
|
||||
if (!goods || !goods.length) return '';
|
||||
return goods
|
||||
.map((g) => {
|
||||
const spec = g.spec ? `(${g.spec})` : '';
|
||||
return `${g.goodsName || '未知商品'}${spec} x${g.totalNum || 1}`;
|
||||
})
|
||||
.join(';');
|
||||
.map((g) => {
|
||||
const spec = g.spec ? `(${g.spec})` : '';
|
||||
return `${g.goodsName || '未知商品'}${spec} x${g.totalNum || 1}`;
|
||||
})
|
||||
.join(';');
|
||||
};
|
||||
|
||||
// 商品总数量:基于实际取到的商品明细求和(订单级 totalNum 列表接口可能不返回,以明细为准)
|
||||
@@ -265,87 +263,87 @@ const handleExport = async () => {
|
||||
]
|
||||
];
|
||||
|
||||
await listShopOrder({ ...where, statusFilter: props.statusFilter })
|
||||
.then(async (list) => {
|
||||
orders.value = list;
|
||||
// 列表接口不返回 orderGoods,按订单逐个补齐商品明细(含名称/规格/数量)
|
||||
const goodsList = await Promise.all(
|
||||
(list ?? []).map((d) =>
|
||||
d.orderId
|
||||
? listShopOrderGoods({ orderId: d.orderId }).catch(() => [])
|
||||
: Promise.resolve([])
|
||||
)
|
||||
);
|
||||
list?.forEach((d: ShopOrder, idx: number) => {
|
||||
array.push([
|
||||
`${d.orderNo || ''}`,
|
||||
`${d.realName || ''}`,
|
||||
`${d.phone || d.mobile || ''}`,
|
||||
`${d.address || ''}`,
|
||||
`${getDeliveryTypeLabel(d.deliveryType)}`,
|
||||
`${getGoodsSummary(goodsList[idx])}`,
|
||||
`${getGoodsTotalNum(goodsList[idx])}`,
|
||||
`${d.payPrice || ''}`,
|
||||
`${
|
||||
d.sendStartTime && d.sendEndTime
|
||||
? `${d.sendStartTime} - ${d.sendEndTime}`
|
||||
: ''
|
||||
}`,
|
||||
`${d.selfTakeCode || ''}`,
|
||||
`${getShopName(d)}`,
|
||||
`${d.buyerRemarks || ''}`,
|
||||
`${getPayType(d.payType)}`,
|
||||
`${getDeliveryStatusLabel(d.deliveryStatus)}`,
|
||||
`${d.createTime || ''}`
|
||||
]);
|
||||
});
|
||||
const sheetName = `订单数据`;
|
||||
const workbook = {
|
||||
SheetNames: [sheetName],
|
||||
Sheets: {}
|
||||
};
|
||||
const sheet = utils.aoa_to_sheet(array);
|
||||
workbook.Sheets[sheetName] = sheet;
|
||||
// 设置列宽(与上方表头一一对应)
|
||||
sheet['!cols'] = [
|
||||
{wch: 22}, // 订单编号
|
||||
{wch: 12}, // 收货人
|
||||
{wch: 16}, // 联系电话
|
||||
{wch: 40}, // 收货地址
|
||||
{wch: 14}, // 配送方式
|
||||
{wch: 40}, // 商品明细
|
||||
{wch: 12}, // 商品总数量
|
||||
{wch: 12}, // 实付金额(元)
|
||||
{wch: 28}, // 配送时间
|
||||
{wch: 12}, // 自提码
|
||||
{wch: 20}, // 发货/自提店铺
|
||||
{wch: 30}, // 买家备注
|
||||
{wch: 12}, // 支付方式
|
||||
{wch: 10}, // 发货状态
|
||||
{wch: 20} // 下单时间
|
||||
];
|
||||
message.loading('正在导出...');
|
||||
setTimeout(() => {
|
||||
writeFile(
|
||||
workbook,
|
||||
`${
|
||||
where.createTimeEnd ? xlsFileName.value + '_' : ''
|
||||
}${sheetName}.xlsx`
|
||||
await listShopOrder({...where, statusFilter: props.statusFilter})
|
||||
.then(async (list) => {
|
||||
orders.value = list;
|
||||
// 列表接口不返回 orderGoods,按订单逐个补齐商品明细(含名称/规格/数量)
|
||||
const goodsList = await Promise.all(
|
||||
(list ?? []).map((d) =>
|
||||
d.orderId
|
||||
? listShopOrderGoods({orderId: d.orderId}).catch(() => [])
|
||||
: Promise.resolve([])
|
||||
)
|
||||
);
|
||||
list?.forEach((d: ShopOrder, idx: number) => {
|
||||
array.push([
|
||||
`${d.orderNo || ''}`,
|
||||
`${d.realName || ''}`,
|
||||
`${d.phone || d.mobile || ''}`,
|
||||
`${d.address || ''}`,
|
||||
`${getDeliveryTypeLabel(d.deliveryType)}`,
|
||||
`${getGoodsSummary(goodsList[idx])}`,
|
||||
`${getGoodsTotalNum(goodsList[idx])}`,
|
||||
`${d.payPrice || ''}`,
|
||||
`${
|
||||
d.sendStartTime && d.sendEndTime
|
||||
? `${d.sendStartTime} - ${d.sendEndTime}`
|
||||
: ''
|
||||
}`,
|
||||
`${d.selfTakeCode || ''}`,
|
||||
`${getShopName(d)}`,
|
||||
`${d.buyerRemarks || ''}`,
|
||||
`${getPayType(d.payType)}`,
|
||||
`${getDeliveryStatusLabel(d.deliveryStatus)}`,
|
||||
`${d.createTime || ''}`
|
||||
]);
|
||||
});
|
||||
const sheetName = `订单数据`;
|
||||
const workbook = {
|
||||
SheetNames: [sheetName],
|
||||
Sheets: {}
|
||||
};
|
||||
const sheet = utils.aoa_to_sheet(array);
|
||||
workbook.Sheets[sheetName] = sheet;
|
||||
// 设置列宽(与上方表头一一对应)
|
||||
sheet['!cols'] = [
|
||||
{wch: 22}, // 订单编号
|
||||
{wch: 12}, // 收货人
|
||||
{wch: 16}, // 联系电话
|
||||
{wch: 40}, // 收货地址
|
||||
{wch: 14}, // 配送方式
|
||||
{wch: 40}, // 商品明细
|
||||
{wch: 12}, // 商品总数量
|
||||
{wch: 12}, // 实付金额(元)
|
||||
{wch: 28}, // 配送时间
|
||||
{wch: 12}, // 自提码
|
||||
{wch: 20}, // 发货/自提店铺
|
||||
{wch: 30}, // 买家备注
|
||||
{wch: 12}, // 支付方式
|
||||
{wch: 10}, // 发货状态
|
||||
{wch: 20} // 下单时间
|
||||
];
|
||||
message.loading('正在导出...');
|
||||
setTimeout(() => {
|
||||
writeFile(
|
||||
workbook,
|
||||
`${
|
||||
where.createTimeEnd ? xlsFileName.value + '_' : ''
|
||||
}${sheetName}.xlsx`
|
||||
);
|
||||
loading.value = false;
|
||||
}, 1000);
|
||||
})
|
||||
.catch((msg) => {
|
||||
message.error(msg);
|
||||
loading.value = false;
|
||||
}, 1000);
|
||||
})
|
||||
.catch((msg) => {
|
||||
message.error(msg);
|
||||
loading.value = false;
|
||||
})
|
||||
.finally(() => {
|
||||
});
|
||||
})
|
||||
.finally(() => {
|
||||
});
|
||||
};
|
||||
|
||||
watch(
|
||||
() => props.selection,
|
||||
() => {
|
||||
}
|
||||
() => props.selection,
|
||||
() => {
|
||||
}
|
||||
);
|
||||
</script>
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -2,7 +2,7 @@
|
||||
<a-page-header :title="getPageTitle()" @back="() => $router.go(-1)">
|
||||
<!-- 高级筛选 -->
|
||||
<a-form layout="inline" class="ele-form-inline" style="margin-bottom: 16px">
|
||||
<a-form-item label="角色">
|
||||
<a-form-item>
|
||||
<a-select
|
||||
v-model:value="searchWhere.roleId"
|
||||
placeholder="全部角色"
|
||||
@@ -17,7 +17,7 @@
|
||||
>
|
||||
</a-select>
|
||||
</a-form-item>
|
||||
<a-form-item label="注册来源">
|
||||
<a-form-item>
|
||||
<a-select
|
||||
v-model:value="searchWhere.platform"
|
||||
placeholder="全部来源"
|
||||
@@ -29,7 +29,7 @@
|
||||
<a-select-option value="WEB">Web</a-select-option>
|
||||
</a-select>
|
||||
</a-form-item>
|
||||
<a-form-item label="类型">
|
||||
<a-form-item>
|
||||
<a-select
|
||||
v-model:value="searchWhere.isAdmin"
|
||||
placeholder="全部"
|
||||
|
||||
Reference in New Issue
Block a user